+3 votes
in Databases by (3.8k 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

0 votes
by (11.2k points)

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);

...