June 17, 2016 at 6:28 am
First I want to thank you guys for your help and suggestions.... I did figure out what was going on and it seems pretty bone head on my part but I am still a novice when it comes to writing query's.
After verifying that CSV was correct and that there were no characters line feeds carriage returns spaces etc. I returned to the parameters for the file input/ bulk insert which is where the problem actually was.
The original code
bulk insert namefile
from 'f:\list.csv'
with (
datafiletype = 'char',
fieldterminator = '","', <======= Problem 1
rowterminator = '\r', <====== Problem 2
errorfile = 'f:\inp_err.log'
);
Which was fine for the single column csv file it read that fine once I added the second column to the csv file it just puked. Once I corrected the code it read the file in correctly with no extra blank record and I was able to query the tables correctly.
Corrected Code
bulk insert namefile
from 'f:\list3.csv'
with (
datafiletype = 'char',
fieldterminator = ',', <===== removed double quotes Not sure what I was thinking there
rowterminator = '/n', <===== new line instead of CR/LF
errorfile = 'f:\inp_err.log'
);
Viewing post 16 (of 15 total)
You must be logged in to reply to this topic. Login to reply