Question: I have seen a number of hacks to try to get the bcp utility to export column names along with the data. If all I am doing is dumping a table to a text file what is the most straightforward method to have bcp add the column headers?

Here's the bcp command I am currently using:

```
bcp myschema.dbo.myTableout myTable.csv /SmyServer01 /c /t, -T

```

Answer: 
From all I know, BCP only exports the data - I don't think there's any way to make it export the header row with column names, too.

One common technique seen to solve this is to use a view over your actual data for export, which basically does a UNION ALL over two statements:

* the first statement to give back one row with the column headers
* the actual data to be export

and then use bcp on that view, instead of your underlying data table directly.

Marc
With a little PowerShell script:

```html
sqlcmd -Q "set nocount on select top 0 * from [DB].[schema].[table]" -o c:\temp\header.txt
bcp [DB].[schema].[table] out c:\temp\query.txt -c -T -S BRIZA
Get-Content c:\temp\*.txt | Set-Content c:\temp\result.txt
Remove-Item c:\temp\header.txt
Remove-Item c:\temp\query.txt
```

Warning: The concatenation follows the .txt file name (in alphabetical order)