Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect syntax near format in BULK INSERT?

I'm trying to figure out why the BULK INSERT command I'm using isn't recognizing the FORMAT and FIELDQUOTE options used in the command.

BULK INSERT dbo.tblM2016_RAW_Current_Import_File
FROM '\\x\tms\SCADA.dat'
WITH
(
    FIRSTROW = 1,
    FORMAT = 'CSV',
    FIELDQUOTE = '"',
    FIELDTERMINATOR = '\t',
    ROWTERMINATOR = '\n'
)

For some reason, I'm getting the error:

Msg 102, Level 15, State 1, Line 6
Incorrect syntax near 'FORMAT'.

Addition: FORMAT shows up in pink text in SSMS, FIELDQUOTE shows in black text, the others show in blue text. It seems the command isn't recognizing FORMAT and FIELDQUOTE as keywords for some reason.

like image 874
Jake Avatar asked Feb 13 '17 14:02

Jake


1 Answers

The FORMAT and FIELDQUOTE specifiers are unfortunately not yet available in production servers.

According to the documentation:

Input file format options
FORMAT = 'CSV'
Applies to: SQL Server vNext CTP 1.1.
Specifies a comma separated values file compliant to the RFC 4180 standard.

FIELDQUOTE = 'field_quote'
Applies to: SQL Server vNext CTP 1.1.

NOTE: This answer is current as of 13th of february 2017. At some point "SQL Server vNext" will cease to be CTP and become production server. The question, however, is in relation to SQL Server 2016 which thus lacks these features.

like image 69
Lasse V. Karlsen Avatar answered Sep 24 '22 07:09

Lasse V. Karlsen