dbTalk Databases Forums  

Bulk insert

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Bulk insert in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Papanii Okai
 
Posts: n/a

Default Bulk insert - 02-10-2006 , 02:10 PM






Hi Guys,
i am a newbie at this stuff and i have a quick question. I would
like to perform a BULK insert into a table. The table contains a couple of
varchars columns, two Guid columns and datetime column. One of the Guid
columns is automatically added newid(), but the other one is a reference id.
Below is an example of the text file i am using...

text-----
comicTypeIDRef, comicName,comicISBN, comicIssueNumber, comicDescription,
comicPublishDate
45E8FBF9-05BC-466D-A4F4-6695BA55BD6D, JLA, 619412081, 125, A world without
the justcice league, 20050920
end text-----

The sample table structure is listed below...

table----
comicTypeIDref (not null, FK, uniqueidentifer)
comicID(pk, uniqueidentifer, newID())
comicName (varchar)
comicISBN (varchar)
comicIssueNumber (int)
comicDescription (ntext)
comicPublishDate (small dateTime)

end Table-------

Now for the bulk insert command...

insert-----

Bulk insert IsotopePortalDB.dbo.comics
from 'c:\test.txt'
with (
CHECK_CONSTRAINTS,
FIRSTROW = 1,
FIELDTERMINATOR = ',' ,
ROWTERMINATOR = '\n'
)


end insert-----

The funny thing is i don't get any errors. The message presented after the
bulk insert is performed is 0 rows affected. When i check table nothing is
there. Could someone point out what i am doing wrong..

Thanx

--Papanii



Reply With Quote
  #2  
Old   
James Wilson
 
Posts: n/a

Default Re: Bulk insert - 02-11-2006 , 07:00 AM






Papanii Okai wrote:
Quote:
Hi Guys,
i am a newbie at this stuff and i have a quick question. I would
like to perform a BULK insert into a table. The table contains a couple of
varchars columns, two Guid columns and datetime column. One of the Guid
columns is automatically added newid(), but the other one is a reference id.
Below is an example of the text file i am using...

text-----
comicTypeIDRef, comicName,comicISBN, comicIssueNumber, comicDescription,
comicPublishDate
45E8FBF9-05BC-466D-A4F4-6695BA55BD6D, JLA, 619412081, 125, A world without
the justcice league, 20050920
end text-----

The sample table structure is listed below...

table----
comicTypeIDref (not null, FK, uniqueidentifer)
comicID(pk, uniqueidentifer, newID())
comicName (varchar)
comicISBN (varchar)
comicIssueNumber (int)
comicDescription (ntext)
comicPublishDate (small dateTime)

end Table-------

Now for the bulk insert command...

insert-----

Bulk insert IsotopePortalDB.dbo.comics
from 'c:\test.txt'
with (
CHECK_CONSTRAINTS,
FIRSTROW = 1,
FIELDTERMINATOR = ',' ,
ROWTERMINATOR = '\n'
)


end insert-----

The funny thing is i don't get any errors. The message presented after the
bulk insert is performed is 0 rows affected. When i check table nothing is
there. Could someone point out what i am doing wrong..

Thanx

--Papanii


Hi Papanii,

It would appear that you need a FORMATFILE because the number of columns
in the file is different from that of the table.
James


Reply With Quote
  #3  
Old   
Papanii Okai
 
Posts: n/a

Default Re: Bulk insert - 02-14-2006 , 12:27 PM



Thanx ..
--Papanii

"James Wilson" <JamesWilson (AT) bryggemail (DOT) dk> wrote

Quote:
Papanii Okai wrote:
Hi Guys,
i am a newbie at this stuff and i have a quick question. I
would like to perform a BULK insert into a table. The table contains a
couple of varchars columns, two Guid columns and datetime column. One of
the Guid columns is automatically added newid(), but the other one is a
reference id. Below is an example of the text file i am using...

text-----
comicTypeIDRef, comicName,comicISBN, comicIssueNumber, comicDescription,
comicPublishDate
45E8FBF9-05BC-466D-A4F4-6695BA55BD6D, JLA, 619412081, 125, A world
without the justcice league, 20050920
end text-----

The sample table structure is listed below...

table----
comicTypeIDref (not null, FK, uniqueidentifer)
comicID(pk, uniqueidentifer, newID())
comicName (varchar)
comicISBN (varchar)
comicIssueNumber (int)
comicDescription (ntext)
comicPublishDate (small dateTime)

end Table-------

Now for the bulk insert command...

insert-----

Bulk insert IsotopePortalDB.dbo.comics
from 'c:\test.txt'
with (
CHECK_CONSTRAINTS,
FIRSTROW = 1,
FIELDTERMINATOR = ',' ,
ROWTERMINATOR = '\n'
)


end insert-----

The funny thing is i don't get any errors. The message presented after
the bulk insert is performed is 0 rows affected. When i check table
nothing is there. Could someone point out what i am doing wrong..

Thanx

--Papanii
Hi Papanii,

It would appear that you need a FORMATFILE because the number of columns
in the file is different from that of the table.
James



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.