Link to home
Start Free TrialLog in
Avatar of Douglass MacLean
Douglass MacLeanFlag for United States of America

asked on

Question about using BULK INSERT to import a .csv or .txt file

My application needs to import data from .csv files created by an Agilent ICP-MS laboratory instrument running under MS Windows. It creates a consistent set of .csv file with column heading in the first row. I have created a table tblFromICPMSRaw with the same column names and each field defined as nvarchar(255),

DELETE FROM  [GSAData].[dbo].[tblFromICPMSRaw]
BULK INSERT  [GSAData].[dbo].[tblFromICPMSRaw]
FROM  '\\NATHONG\GSAJDrive\InstrumentOutputFiles\ICPMS\New\182023.csv'
WITH (Codepage = 'ACP', Datafiletype = 'char', Fieldterminator = ',', Firstrow = 2)

It works just fine, with me specifying FIRSTROW = 2 to not import the column headers (Row # 1)

But I found this note in the Transact SQL definition of Bulk Insert
" Note:
The FIRSTROW attribute is not intended to skip column headers. Skipping headers is not supported by the BULK INSERT statement. When skipping rows, the SQL Server Database Engine looks only at the field terminators, and does not validate the data in the fields of skipped rows. "

What, if any, risk am I running by ignoring this note?
ASKER CERTIFIED SOLUTION
Avatar of plusone3055
plusone3055
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Douglass MacLean

ASKER

Good enough for me. I'll proceed to use Firstrow = 2 knowing I am in good company.