question

tamara avatar image
tamara asked

bulk insert with QUOTE DELIMITER

i have the following csv file layout. "8-13 13:52:13",,"Tyre Inspection"," tyres@books.com","Tyres","tmfo","4af2eb33d962ac0f-1407838105495","08/12/2014." I want to do a BULK INSERT. The fields are comma delimited but also double quote delimited. Is there a way to 'remove' the double quotes or a 'sql' query that would import these types of files? Table def is something like this; create table tyreinspections_temp (StartDate varchar(1032), EndDate varchar(1032), SubmissionNumber varchar(255), ExportAppName varchar(1032), Username varchar(1032), UserLastName varchar(1032), UserFirstName varchar(1032), ResponseID varchar(255), ResponseDateTime varchar(1032), DeviceDateTime varchar(1032) ) The sql query that i'm using is; set @sql = 'BULK INSERT tyreinspections_temp FROM ''' + @path + @filename + ''' ' + ' WITH ( FIELDTERMINATOR ='","', ROWTERMINATOR = ''\n'', FIRSTROW = 2 ) ' This query gives me an incorrect syntax error on the FIELDTERMINATOR part. please help me.
sqlserver2008r2
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.