Click here to Skip to main content
16,011,702 members

Comments by Member 11027043 (Top 1 by date)

Member 11027043 22-Oct-15 23:30pm View    
Hi, this code works perfectly :)

DECLARE @cmd VARCHAR(255)
SET @cmd = 'bcp "My Select Query Here" queryout "My Excel File Path Here" -U sqluserHere -P sqlpasswordHere -c'
Exec xp_cmdshell @cmd

But I need the column name.
How can I get the column name at the first row in my excel?