Import CSV file to SQL server.

It is very convenient to use Access import wizard to load data into a table and later the table can be moved between access and SQL Server.  This task can be done through BULK INSERT. First thing is to remove the header row manually for the CSV file and save the file. Yes, there is a property we might attempt to use: FIRSTROW. But there is Note on Books Online:"The FIRSTROW attribute is not intended to skip column headers. When skipping rows, the SQL Server Database Engine looks only at the field terminators, and does not valid the data in the fields of skipped rows." Second thing is to create a table with corresponding columns in taget datatbase; and finally use the following BULK INSERT script in MSSMS query window:

BULK INSERT thetable FROM ‘c:\theCSVFileWithoutHeading.csv’




= ‘,’,


= ‘\n’



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s