Varshini S
asked on
SQL QUERY TO CSV WITH COLUMN HEADER
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
select @sql = 'bcp "exec '+ 'usp_EmployeeDetails]'''+ @myDate+ '''" queryout ' + @Path + '.csv -c -t, -T -S'+ @@sname
EXEC master..xp_cmdshell @sql
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the way to do this is use a query like so:
Open in new window