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,
is an optional parameter specifying the name of the database. It can only be omitted if the desired database is the default database.
the name of the table owner.
the name of the table.
The name of the comma separated file to generate.
The SQL Server username to use. This can be left blank if NT authentication is used.
The password to use for the account.
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.
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: Brian Cryer 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.