Cry How to...

Import Data from a Comma Separated File

To import data from a comma separated file (csv), use bcp:

bcp [<database-name.>][<owner.>]<table-name> in <csv-file> [/U<username>] [/P<password>] [/S<server-name>] /c /t,


<database-name> is an optional parameter specifying the name of the database. It can only be omitted if the desired database is the default database.
<owner> the name of the table owner.
<table-name> the name of the table.
<csv-file> The name of the comma separated file to generate.
<username> The SQL Server username to use. This can be left blank if NT authentication is used.
<password> The password to use for the account.
<server-name> The name of the server on which the database resides. This can be omitted if the database is local.


  • The flags are case sensitive.

  • The table should expect the fields in the same order as they are saved in the file.

for example:

bcp mydb.dbo.sales in sales.csv /U /P /Ssales_fs /c /t,

These notes have been tested against SQL Server 7.

About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.