+3 votes
in Databases by (56.5k points)
I am loading data from .csv files to the SQL server using BULK INSERT command, but the first row in each csv file is the column name. I want to skip the first row so that BULK INSERT doesn't give error. How can I do that?

1 Answer

+2 votes
by (71.8k points)
selected by
 
Best answer

You can specify FIRSTROW=2 in your BULK INSERT command to skip the very first row. See the below example.
 

BULK INSERT mytable
FROM 'E:\XXXXX\mytable.txt'
WITH (FIELDTERMINATOR ='\t', ROWTERMINATOR = '\n',FIRSTROW = 2);


...