• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 107
  • Last Modified:

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?
0
Douglass MacLean
Asked:
Douglass MacLean
1 Solution
 
plusone3055Commented:
Thats an age old debate across  hundreds of SQL forums. I used Firstrow = 2 myself  for years and Have not come across any issues. I wish MSDN would offer more insight on those 3 sentences.
0
 
Douglass MacLeanCTOAuthor Commented:
Good enough for me. I'll proceed to use Firstrow = 2 knowing I am in good company.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now