hello smart helpful people i am tryin to import a CSV into an SQL database. i am using the code below but it does not work because some column has , in its value. example "Auto Recyclers, Ltd." is there a way to import this correctly. [SQL] BULK INSERT junkyards FROM 'c:\junkyards.csv' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO [/SQL] example row link,"DD Engines, Inc.",44 Highway 231 ,Hazel Green,Alabama,35750,fax,phone2,phone1,url,Specializing in used and rebuilt engines
You will likely have to escape all commas between quotes in the CSV file using a backslash \ Ex. link,"DD Engines\, Inc.",44 Highway 231 ,Hazel Green,Alabama,35750,fax,phone2,phone1,url,Specializing in used and rebuilt engines
Upon further research it seams my initial solution is incorrect. I would take a look at this stack overflow post who had a similar issue: http://stackoverflow.com/questions/4123875/commas-within-csv-data
The csv spec calls for any text field with a comma to be quoted: 300, xxx, "Auto Recyclers, Ltd.", Auto Recyclers, ... To make life simpler, every text field can be quoted and it will still work.