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)
yes,you're right...I tried my self append 2 xls files and it didn't work , but I did't thought of 2 txt files append in an xls-files.Very ingenious.Thanks a lot!!! I will try it and come back to you..