October 10, 2007 at 11:07 pm
Hi
I am using bulk insert to upload .csv file to sql server.
The first 3 rows of my file contain different format than the
rest of the file.I am using FIRSTROW to skip 3 rows,but it is giving me an error :
[Could not bulk insert because column too long in data file. Make sure FieldTerminator and RowTerminator were specified correctly]
My file looks like :
STOCK EXCHANGE
DAILY TRANSACTION
-----------------------
itemcode,name,stock
1,pen,10
2,pencil,20
3,eraser,30
I think reason of error is that first 3 rows dont contain field terminator(which is comma) .
Plz help me to skip first 3 rows
October 11, 2007 at 2:49 am
after copying your example to G:\bulk1.txt:
BULK INSERT bulk1 FROM 'G:\bulk1.txt' WITH ( FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n', FIRSTROW = 2 )
seems to work for me. Are you specifying the field terminator?
Also, just for debugging purposes, if you manually remove the first three lines, do you get the same error?
Regards,
Andras
October 11, 2007 at 4:36 am
Thanks for reply
October 12, 2007 at 10:28 pm
Hello Sir
Thanks for your reply.
I am using the same procedure as you mentioned,But no luck.
I am getting error like this :
[The line is too long for row 1 column 3.Verify that field terminator and row terminator are specified correctly]
May I know ur email id, so that I can mail my sample .csv file to you.
Plz help
Regards
Jeet
October 13, 2007 at 10:56 am
Could be any of a dozen different problems... you need to post the code you're using and the CREATE statement for the table you are importing to.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 15, 2007 at 2:17 am
I've sent you my email address in a pm, but there are many experienced people looking at these forums, so instead of email it would be nicer if you posted, as Jeff mentioned: the schema of the table, the exact statement you are executing for the bulk insert, and the first part of the file. This will not only let others answer your question, but the resolution will stay here for people who experience the same problem in the future.
Regards,
Andras
October 15, 2007 at 5:24 am
i would lean towards the data not being in the expected format....maybe it's a unix based file, and contains only \r for the rowterminator and not , which is Carriage Return Line feed.
but we wont know without more details.
Lowell
November 19, 2007 at 8:22 am
Could it be that you actually need to skip the first 4 rows? Looks like your 3rd row is actually the headers for the columns, and 'itemcode' & 'stock' probably wouldn't fit into columns expecting int. Just a thought.
shirish_padekar (10/10/2007)
HiI am using bulk insert to upload .csv file to sql server.
The first 3 rows of my file contain different format than the
rest of the file.I am using FIRSTROW to skip 3 rows,but it is giving me an error :
[Could not bulk insert because column too long in data file. Make sure FieldTerminator and RowTerminator were specified correctly]
My file looks like :
STOCK EXCHANGE
DAILY TRANSACTION
-----------------------
itemcode,name,stock
1,pen,10
2,pencil,20
3,eraser,30
I think reason of error is that first 3 rows dont contain field terminator(which is comma) .
Plz help me to skip first 3 rows
November 19, 2007 at 5:12 pm
Even with that, it's still gonna blow up... the skipped rows have to have the same format as those that aren't. It's a fault in both Bulk Insert and BCP. I get around it by writting some VBS...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply