I have the following. How can I export to CSV and include the column names in the first row of the CSV file?
The following works but does not include the column names.
ALTER procedure [dbo].[EXPORT_TO_CSV]
@SQL NVARCHAR(4000), @FilePath nVARCHAR(200)
declare @s varchar(5000)
set @s = 'bcp "'+ @SQL + '" queryout ' + @FilePath + ' -c -t, -T'
exec master..xp_cmdshell @s