I am using SQL Server 2017 Developer edition. I have a table of 5 columns out of which 1st one is identity and 4th is having default constraint and the 5th one is computed column. So in CSV, I am not providing values for these three columns.
I have created a format file to skip the first column. This was working in SQL 2014 but now when I do same in SQL 2017 using Format = CSV parameter it throws an error.
Cannot bulk load CSV file. Invalid field parameters are specified for source column number 1 in the format file "C:\MyData\Archives\Demo.fmt". All data fields must be either character or Unicode character with terminator when CSV format is specified.
Cannot bulk load. Invalid number of columns in the format file "C:\MyData\Archives\Demo.fmt".
Am I missing anything here? Any help would be really appreciated.
CREATE table dbo.test
(
[UniqueID] [bigint] IDENTITY(1,1) NOT NULL,
[Id] char NOT NULL,
[Name] [varchar] (50) NOT NULL,
[IsDelete] [tinyint] NULL DEFAULT 0,
[HashValue] AS (checksum('MD5',[Id],[Name])) PERSISTED
);
CSV
"UniqueId","Id","Name","IsDelete"
"A101","John"
"B102","Scott"
Demo.fmt
14.0
3
1 SQLCHAR 0 1 "" 0 FIRST_QUOTE ""
2 SQLCHAR 0 9999 ","" 2 Id ""
3 SQLCHAR 0 9999 ""\r\n" 3 Name ""
BULK INSERT dbo.test from 'C:\MyData\CONTENT\Input.csv'
WITH ( FORMAT = 'CSV', FIRSTROW = 2, FormatFile = 'C:\MyData\Archives\Demo.fmt')