I have a csv file that has column values enclosed within double quotes.
I want to import a csv file from a network path using an sql statement.
I tried bulk insert. But it imports along with double quotes. Is there any other way to import a csv file into SQL Server 2008 using an sql statement by ignoring the text qualifier double quote?
Thanks
-Vivek
You could use a non-xml format file to specify a different delimiter per column. For values enclosed with double quotes, and delimited by tabs, the delimiter could be
\",\". You’d have to add an initial unused column to capture the first quote. For example, to read this file:You could use this format file:
(The number on the first line depends on the SQL Server version. The number on the second line is the number of columns to read. Don’t forget to adjust it.)
The
bulk insertcommand accepts aformatfile = 'format_file_path'parameter where you can specify the format file. For example:This results in: