![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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, |
#3
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |