none
SQL results to CSV file with column headers

    Question

  • Hi

    I am exporting SQL results into CSV file using BCP, I need to include column headers for the report. Any help is appreciated.

    Below is my code

    set @sql = 'bcp "select * from Sam.dbo.Samtmp" queryout '+@SAMLog_file_location+' -c -T -S' + convert(varchar,@@servername);
    exec master..xp_cmdshell @sql

    Thursday, February 07, 2013 3:43 PM

Answers

All replies