Sunday, February 19, 2012

Bulk Copy into CSV file with column name

Hi
i am exporting a data from table to CSV file using BCP command
but only the data are exported in CSV file,actually i want column name also in CSV file.
Appreciate your help for this issue

Thanks in Advance

You can't do it with bcp. You can either add the columns by hand, or write some fancy SQL to retrieve the column names from the syscolumns table. You'd probably have to do it in a DTS package.|||You can use a query that contains the header row and orders the data appropriately. See http://www.umachandar.com/technical/SQL70Scripts/Main8.htm for an example. Note that with this approach you will have to convert all the data to string format.

No comments:

Post a Comment