March 22, 2014 at 6:35 am
I am using bcp to generate text files. Is there a way to generate header in the file with Bcp?
March 22, 2014 at 12:08 pm
Yes. If you use the queryout option and use union all to link a column list with the actual content.bcp "SELECT 'col1', 'col2', 'col3' U NION ALL SELECT col1, col2, col3 FROM MyTable" queryout MyTable.csv /MyServerName /c /t, -T
You can find decent working examples in the links below:
http://connect.microsoft.com/SQLServer/feedback/details/288800/b c p-out-to-include-field-columns-names
Note spaces added "U NION" ALL to avoid proxy issues on my end, so remove those
______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply