BULK INSERT examples to import CSV / TSV files into SQL Server.
CSV file
BULK INSERT OrdersBulkTSV file, tab-separated values
FROM 'c:\file.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
BULK INSERT OrdersBulk---
FROM 'c:\file.csv'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n'
)
BULK INSERT OrdersBulkFIRSTROW parameter
FROM 'c:\file.csv'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\t\n'
)
BULK INSERT OrdersBulk---
FROM 'c:\file.csv'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
BULK INSERT OrdersBulk---
FROM 'c:\file.csv'
WITH
(
FIRSTROW = 2,
MAXERRORS = 0,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
No comments:
Post a Comment