Wednesday, March 28, 2012
Person.Coontact - AdventureWorks
The Table Person.Contact is empty. I have the .csv file for the data for
this table. This .csv seems to be xml data.
How can I get this particular .csv into this table?
I basically would like to somehow populate this particular table.
Thanks
If you look at the installation script for AdventureWorks (instawdb.sql),
you'll find a series of BULK INSERT statements that load all the .csv files
for the database. Here's the statement for the Person.Contact table. I
simply modified the statement to point to the location of the .csv file on
my server.
EXECUTE (N'BULK INSERT [Person].[Contact]
FROM ''C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks
OLTP\Contact.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE=''widechar'',
FIELDTERMINATOR=''+|'',
ROWTERMINATOR=''&|\n'',
KEEPIDENTITY,
TABLOCK
);');
However, unless you know for sure that the Person.Contact table is the only
empty table, you may want to recreate the entire database by running the
installation script. The instructions for doing this are in Books Online in
the topic "Reinstalling Sample Databases From Scripts".
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"farshad" <farshad@.discussions.microsoft.com> wrote in message
news:44F58336-3BAD-4EC9-868B-0FD6AD3DA921@.microsoft.com...
>I have the AdventureWorks database in sql server 2005.
> The Table Person.Contact is empty. I have the .csv file for the data for
> this table. This .csv seems to be xml data.
> How can I get this particular .csv into this table?
> I basically would like to somehow populate this particular table.
> Thanks
|||Ran the following script:
EXECUTE (N'BULK INSERT [Person].[Contact]
FROM ''C:\Program Files\Microsoft SQL Server 2005 AdventureWorks Sample
Database Scripts\awdb\Contact.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE=''widechar'',
FIELDTERMINATOR=''+|'',
ROWTERMINATOR=''&|\n'',
KEEPIDENTITY,
TABLOCK
);');
It gave the following error. thanks
XML Validation: Declaration not found for element
'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRecord:ContactRecord'. Location: /*:AdditionalContactInfo[1]/*:ContactRecord[1]
"Gail Erickson [MS]" wrote:
> If you look at the installation script for AdventureWorks (instawdb.sql),
> you'll find a series of BULK INSERT statements that load all the .csv files
> for the database. Here's the statement for the Person.Contact table. I
> simply modified the statement to point to the location of the .csv file on
> my server.
> EXECUTE (N'BULK INSERT [Person].[Contact]
> FROM ''C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks
> OLTP\Contact.csv''
> WITH (
> CHECK_CONSTRAINTS,
> CODEPAGE=''ACP'',
> DATAFILETYPE=''widechar'',
> FIELDTERMINATOR=''+|'',
> ROWTERMINATOR=''&|\n'',
> KEEPIDENTITY,
> TABLOCK
> );');
> However, unless you know for sure that the Person.Contact table is the only
> empty table, you may want to recreate the entire database by running the
> installation script. The instructions for doing this are in Books Online in
> the topic "Reinstalling Sample Databases From Scripts".
> --
> Gail Erickson [MS]
> SQL Server Documentation Team
> This posting is provided "AS IS" with no warranties, and confers no rights
> "farshad" <farshad@.discussions.microsoft.com> wrote in message
> news:44F58336-3BAD-4EC9-868B-0FD6AD3DA921@.microsoft.com...
>
>
|||> It gave the following error. thanks
Then you have more problems than just an empty table. You need to follow
the instructions in the Books Online topic "Reinstalling Sample Databases
From Scripts". This will drop the database and recreate it.
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"farshad" <farshad@.discussions.microsoft.com> wrote in message
news:9D8C349E-B64E-4D5D-B4D9-DF7A0D04C917@.microsoft.com...[vbcol=seagreen]
> Ran the following script:
> EXECUTE (N'BULK INSERT [Person].[Contact]
> FROM ''C:\Program Files\Microsoft SQL Server 2005 AdventureWorks Sample
> Database Scripts\awdb\Contact.csv''
> WITH (
> CHECK_CONSTRAINTS,
> CODEPAGE=''ACP'',
> DATAFILETYPE=''widechar'',
> FIELDTERMINATOR=''+|'',
> ROWTERMINATOR=''&|\n'',
> KEEPIDENTITY,
> TABLOCK
> );');
> It gave the following error. thanks
> XML Validation: Declaration not found for element
> 'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRecord:ContactRecord'.
> Location: /*:AdditionalContactInfo[1]/*:ContactRecord[1]
>
> "Gail Erickson [MS]" wrote:
Person.Coontact - AdventureWorks
The Table Person.Contact is empty. I have the .csv file for the data for
this table. This .csv seems to be xml data.
How can I get this particular .csv into this table?
I basically would like to somehow populate this particular table.
ThanksIf you look at the installation script for AdventureWorks (instawdb.sql),
you'll find a series of BULK INSERT statements that load all the .csv files
for the database. Here's the statement for the Person.Contact table. I
simply modified the statement to point to the location of the .csv file on
my server.
EXECUTE (N'BULK INSERT [Person].[Contact]
FROM ''C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks
OLTP\Contact.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE=''widechar'',
FIELDTERMINATOR=''+|'',
ROWTERMINATOR=''&|\n'',
KEEPIDENTITY,
TABLOCK
);');
However, unless you know for sure that the Person.Contact table is the only
empty table, you may want to recreate the entire database by running the
installation script. The instructions for doing this are in Books Online in
the topic "Reinstalling Sample Databases From Scripts".
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"farshad" <farshad@.discussions.microsoft.com> wrote in message
news:44F58336-3BAD-4EC9-868B-0FD6AD3DA921@.microsoft.com...
>I have the AdventureWorks database in sql server 2005.
> The Table Person.Contact is empty. I have the .csv file for the data for
> this table. This .csv seems to be xml data.
> How can I get this particular .csv into this table?
> I basically would like to somehow populate this particular table.
> Thanks|||Ran the following script:
EXECUTE (N'BULK INSERT [Person].[Contact]
FROM ''C:\Program Files\Microsoft SQL Server 2005 AdventureWorks Sample
Database Scripts\awdb\Contact.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE=''widechar'',
FIELDTERMINATOR=''+|'',
ROWTERMINATOR=''&|\n'',
KEEPIDENTITY,
TABLOCK
);');
It gave the following error. thanks
XML Validation: Declaration not found for element
'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRecor
d:ContactRecord'. Location: /*:AdditionalContactInfo[1]/*:ContactRecord&
#91;1]
"Gail Erickson [MS]" wrote:
> If you look at the installation script for AdventureWorks (instawdb.sql),
> you'll find a series of BULK INSERT statements that load all the .csv file
s
> for the database. Here's the statement for the Person.Contact table. I
> simply modified the statement to point to the location of the .csv file on
> my server.
> EXECUTE (N'BULK INSERT [Person].[Contact]
> FROM ''C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWor
ks
> OLTP\Contact.csv''
> WITH (
> CHECK_CONSTRAINTS,
> CODEPAGE=''ACP'',
> DATAFILETYPE=''widechar'',
> FIELDTERMINATOR=''+|'',
> ROWTERMINATOR=''&|\n'',
> KEEPIDENTITY,
> TABLOCK
> );');
> However, unless you know for sure that the Person.Contact table is the onl
y
> empty table, you may want to recreate the entire database by running the
> installation script. The instructions for doing this are in Books Online
in
> the topic "Reinstalling Sample Databases From Scripts".
> --
> Gail Erickson [MS]
> SQL Server Documentation Team
> This posting is provided "AS IS" with no warranties, and confers no rights
> "farshad" <farshad@.discussions.microsoft.com> wrote in message
> news:44F58336-3BAD-4EC9-868B-0FD6AD3DA921@.microsoft.com...
>
>|||> It gave the following error. thanks
Then you have more problems than just an empty table. You need to follow
the instructions in the Books Online topic "Reinstalling Sample Databases
From Scripts". This will drop the database and recreate it.
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"farshad" <farshad@.discussions.microsoft.com> wrote in message
news:9D8C349E-B64E-4D5D-B4D9-DF7A0D04C917@.microsoft.com...[vbcol=seagreen]
> Ran the following script:
> EXECUTE (N'BULK INSERT [Person].[Contact]
> FROM ''C:\Program Files\Microsoft SQL Server 2005 AdventureWorks Sample
> Database Scripts\awdb\Contact.csv''
> WITH (
> CHECK_CONSTRAINTS,
> CODEPAGE=''ACP'',
> DATAFILETYPE=''widechar'',
> FIELDTERMINATOR=''+|'',
> ROWTERMINATOR=''&|\n'',
> KEEPIDENTITY,
> TABLOCK
> );');
> It gave the following error. thanks
> XML Validation: Declaration not found for element
> 'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRec
ord:ContactRecord'.
> Location: /*:AdditionalContactInfo[1]/*:ContactRecord[1]
>
> "Gail Erickson [MS]" wrote:
>
Person.Coontact - AdventureWorks
The Table Person.Contact is empty. I have the .csv file for the data for
this table. This .csv seems to be xml data.
How can I get this particular .csv into this table?
I basically would like to somehow populate this particular table.
ThanksIf you look at the installation script for AdventureWorks (instawdb.sql),
you'll find a series of BULK INSERT statements that load all the .csv files
for the database. Here's the statement for the Person.Contact table. I
simply modified the statement to point to the location of the .csv file on
my server.
EXECUTE (N'BULK INSERT [Person].[Contact]
FROM ''C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks
OLTP\Contact.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE=''widechar'',
FIELDTERMINATOR=''+|'',
ROWTERMINATOR=''&|\n'',
KEEPIDENTITY,
TABLOCK
);');
However, unless you know for sure that the Person.Contact table is the only
empty table, you may want to recreate the entire database by running the
installation script. The instructions for doing this are in Books Online in
the topic "Reinstalling Sample Databases From Scripts".
--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"farshad" <farshad@.discussions.microsoft.com> wrote in message
news:44F58336-3BAD-4EC9-868B-0FD6AD3DA921@.microsoft.com...
>I have the AdventureWorks database in sql server 2005.
> The Table Person.Contact is empty. I have the .csv file for the data for
> this table. This .csv seems to be xml data.
> How can I get this particular .csv into this table?
> I basically would like to somehow populate this particular table.
> Thanks|||Ran the following script:
EXECUTE (N'BULK INSERT [Person].[Contact]
FROM ''C:\Program Files\Microsoft SQL Server 2005 AdventureWorks Sample
Database Scripts\awdb\Contact.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE=''widechar'',
FIELDTERMINATOR=''+|'',
ROWTERMINATOR=''&|\n'',
KEEPIDENTITY,
TABLOCK
);');
It gave the following error. thanks
XML Validation: Declaration not found for element
'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRecord:ContactRecord'. Location: /*:AdditionalContactInfo[1]/*:ContactRecord[1]
"Gail Erickson [MS]" wrote:
> If you look at the installation script for AdventureWorks (instawdb.sql),
> you'll find a series of BULK INSERT statements that load all the .csv files
> for the database. Here's the statement for the Person.Contact table. I
> simply modified the statement to point to the location of the .csv file on
> my server.
> EXECUTE (N'BULK INSERT [Person].[Contact]
> FROM ''C:\Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks
> OLTP\Contact.csv''
> WITH (
> CHECK_CONSTRAINTS,
> CODEPAGE=''ACP'',
> DATAFILETYPE=''widechar'',
> FIELDTERMINATOR=''+|'',
> ROWTERMINATOR=''&|\n'',
> KEEPIDENTITY,
> TABLOCK
> );');
> However, unless you know for sure that the Person.Contact table is the only
> empty table, you may want to recreate the entire database by running the
> installation script. The instructions for doing this are in Books Online in
> the topic "Reinstalling Sample Databases From Scripts".
> --
> Gail Erickson [MS]
> SQL Server Documentation Team
> This posting is provided "AS IS" with no warranties, and confers no rights
> "farshad" <farshad@.discussions.microsoft.com> wrote in message
> news:44F58336-3BAD-4EC9-868B-0FD6AD3DA921@.microsoft.com...
> >I have the AdventureWorks database in sql server 2005.
> > The Table Person.Contact is empty. I have the .csv file for the data for
> > this table. This .csv seems to be xml data.
> > How can I get this particular .csv into this table?
> > I basically would like to somehow populate this particular table.
> > Thanks
>
>|||> It gave the following error. thanks
Then you have more problems than just an empty table. You need to follow
the instructions in the Books Online topic "Reinstalling Sample Databases
From Scripts". This will drop the database and recreate it.
--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"farshad" <farshad@.discussions.microsoft.com> wrote in message
news:9D8C349E-B64E-4D5D-B4D9-DF7A0D04C917@.microsoft.com...
> Ran the following script:
> EXECUTE (N'BULK INSERT [Person].[Contact]
> FROM ''C:\Program Files\Microsoft SQL Server 2005 AdventureWorks Sample
> Database Scripts\awdb\Contact.csv''
> WITH (
> CHECK_CONSTRAINTS,
> CODEPAGE=''ACP'',
> DATAFILETYPE=''widechar'',
> FIELDTERMINATOR=''+|'',
> ROWTERMINATOR=''&|\n'',
> KEEPIDENTITY,
> TABLOCK
> );');
> It gave the following error. thanks
> XML Validation: Declaration not found for element
> 'http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactRecord:ContactRecord'.
> Location: /*:AdditionalContactInfo[1]/*:ContactRecord[1]
>
> "Gail Erickson [MS]" wrote:
>> If you look at the installation script for AdventureWorks (instawdb.sql),
>> you'll find a series of BULK INSERT statements that load all the .csv
>> files
>> for the database. Here's the statement for the Person.Contact table. I
>> simply modified the statement to point to the location of the .csv file
>> on
>> my server.
>> EXECUTE (N'BULK INSERT [Person].[Contact]
>> FROM ''C:\Program Files\Microsoft SQL
>> Server\90\Tools\Samples\AdventureWorks
>> OLTP\Contact.csv''
>> WITH (
>> CHECK_CONSTRAINTS,
>> CODEPAGE=''ACP'',
>> DATAFILETYPE=''widechar'',
>> FIELDTERMINATOR=''+|'',
>> ROWTERMINATOR=''&|\n'',
>> KEEPIDENTITY,
>> TABLOCK
>> );');
>> However, unless you know for sure that the Person.Contact table is the
>> only
>> empty table, you may want to recreate the entire database by running the
>> installation script. The instructions for doing this are in Books Online
>> in
>> the topic "Reinstalling Sample Databases From Scripts".
>> --
>> Gail Erickson [MS]
>> SQL Server Documentation Team
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights
>> "farshad" <farshad@.discussions.microsoft.com> wrote in message
>> news:44F58336-3BAD-4EC9-868B-0FD6AD3DA921@.microsoft.com...
>> >I have the AdventureWorks database in sql server 2005.
>> > The Table Person.Contact is empty. I have the .csv file for the data
>> > for
>> > this table. This .csv seems to be xml data.
>> > How can I get this particular .csv into this table?
>> > I basically would like to somehow populate this particular table.
>> > Thanks
>>sql
Monday, March 12, 2012
Permissions and access to AdventureWorks
I have downloaded the Express Edition of SQL Server 2005 to try to learn the software to take the MCTS test for certification. I have installed the software and the SMS. I have downloaded the AdventureWorks database files and installed everything as directed. I use Windows authentication to log in (it's my own home PC). I have followed the instructions to attach the database to the instance I am using.
The problem I'm having is in trying to run examples from the book I'm using on the database. For example, I'm trying to run a simple query like "SELECT * FROM dbo.DatabaseLog;" When I click execute, I keep getting this message:
"
Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.DatabaseLog'.
"
When I look at the Object Explorer pane, I can clearly see the table and see that I am spelling it correctly.
I have set my login up as the owner of the database and when I try to set up permissions on the table, I only see the roles [user] and [guest]. I tried setting up permissions for both, but that didn't help.
What am I doing wrong?
Thank you.
Eric S. Bauman
Be sure to be under the specific Northwind database context if you start the query. There is a dropdown in SSMS where you can change the context through the GUI. YOu can also change the context through the USE command e.g. USE Northwind or directly during connection time specifying Initital Catalog=Northwind in the connectionstring (you did not mention where you tried to execute the query)Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||Thank you, Jens. That did it. I opened up a new query window in SMS, typed in the USE command then typed in the query and it worked like a champ.
Thanks again for your help!
Eric Bauman