Sunday, February 19, 2012

Column Heading in Output File

Hi
I am running a SQL query and printing the output to a file, as well as
showing it in the Grid. The Grid has column headings, my file does not. Is
there a way of getting my column headings into the output file?
To create the output file I am using the following;
EXEC master..xp_cmdshell 'bcp "DATABASE.dbo.FILE" out
"C:\SQLSCRIPT\OUTPUT.txt" -c -t, -q -Sserver -U"username" -P"password"'
GO
Any help appreciated.
SteveBCP will not export the headings. You can use OSQL to do that.
Rand
This posting is provided "as is" with no warranties and confers no rights.

No comments:

Post a Comment