Sica writes "How can I make BCP output the field names along with the data? I BCP out to a xls-file and need to have the field names be the first row in the table. EX: EXEC('exec master..xp_cmdshell ''BCP "' + @DatabaseName + '..' + @TableName + '" OUT ' + @Path + @TableName + '.xls /SSLQSERVER /Usa /Psa@sa -t \t /r\n /c -C ACP -q''')"
BCP can't do this, but DTS can. You may be able to BCP the column names from the INFORMATION_SCHEMA views, using a tab (\t) as a row delimiter, and then use the DOS COPY command to append this file with the data. (I'll try it and will post the code if I'm successful)