How can I call BCP (bulk copy SQl Server) with Header columns in C# to export data from sql server to a text file.
Can you show me some examples?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Feb 15, 2014, 5:42 PM
http://social.msdn.microsoft.com/Forums/en-US/cfb40e41-d6c9-4b0c-a1de-c10230588fcc/bcp-utility-using-c-?forum=adodotnetdataproviders
Unfortunately, the BCP utility doesn't have a straightforward option to include column headers with the data. However, I found another link where someone's had the bright idea of using the 'queryout' option and then using UNION ALL to link a list of column headers with the rows of the datatable:
http://stackoverflow.com/questions/1355876/export-table-to-file-with-column-headers-column-names-using-the-bcp-utility-an
Hopefully, you'll be able to figure something out from this.
j cPosted Feb 17, 2014, 9:57 AM