I am using following BCP command to export the SQL out put to CVS file. But it is missing the column header. How do I add the column header in the CSV out put ?
select @sql = 'bcp "exec '+ 'usp_EmployeeDetails]'''+ @myDate+ '''" queryout ' + @Path + '.csv -c -t, -T -S'+ @@sname
EXEC master..xp_cmdshell @sql
the way to do this is use a query like so:
Open in new window