Jump to Navigation

sql

298 - BULK INSERT with identity (auto-increment) column

1. Add an id column to the csv file and leave it blank:

------------------------------------------------------------

id,Name,Address
,name1,addr test 1
,name2,addr test 2

------------------------------------------------------------

2. Remove KEEPIDENTITY keyword from query:

BULK INSERT Employee  FROM 'path\tempFile.csv '
WITH (FIRSTROW = 2,FIELDTERMINATOR = ',' , ROWTERMINATOR = '\n');

Mssql:
Subscribe to RSS - sql


Main menu 2

by Dr. Radut