Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mavericky
Posting Yak Master
117 Posts |
Posted - 2011-06-29 : 11:38:24
|
| Hi All,Can you please tell me what is wrong in this bulk insert statement?BULK INSERT RTO FROM '\\amolp-d\D$\RTO.csv' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n', FIRSTROW = 2 )I get this result: (0 row(s) affected)Data in excel sheet:ID Name ShortName Comments StartDT EndDT UpdateDT1 ISO New England NE RTO 1 5/8/2007 12:35 5/8/2009 12:35 5/8/2008 12:35ID is identity column in database.Thanks in anticipation,Mavericky |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-29 : 11:45:29
|
| I assume it's not really an excel file.Try importing into a single column table so you can see what the data looks like and whether the terminators are recognised.You need the keepidentity flag set if it is to be imported - should just be ignored in this case.You don't appear to have any column terminators (,) in the file.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
mavericky
Posting Yak Master
117 Posts |
Posted - 2011-06-29 : 11:55:46
|
| Thanks for the reply!! Actually it was a .xlsx file. I renamed it to .csv. I don't have any column terminators. It is still not inserting any rows.Amol |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-29 : 12:11:28
|
| You won't be able to - try looking at the file in notepad and you'll see why. Why did you rename it?The bulk insert specifies a comma as a column terminatorI'm wondering why you expect that command to import this file - think I'm missing something.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
mavericky
Posting Yak Master
117 Posts |
Posted - 2011-06-29 : 12:27:12
|
| Thanks a lot nigelrivett!!!I edited an existing csv file and put my data there. The data got imported in my database.Mavericky |
 |
|
|
|
|
|