I am using BCP to export SQL table to CSV and it works great. but it doesn't include the header - Column name. I need to include it ;-(
Below is my T-SQL.
Declare @sql varchar(8000)
select @sql = 'bcp "select * from Table" queryout C:\ -c -t, -T -S' + @@servername
exec master..xp_cmdshell @sql