Wednesday, March 28, 2012

Person.Coontact - AdventureWorks

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.
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

No comments:

Post a Comment