bcp "select * from northwind..orders" queryout
c:\cust.xls -c -SMDC-MHP1DXP0025\PREDATOR -Usa -P
above command will create a file with extension XLS but, in fact its a tab
delimited flat file . Since it has extension XLS by default it will get
opened in EXCEL assuming tab as a column delimiter.
I've put TAB as a column delimiter assuming this character is not used in
any of the varchar/char field. because if you are including such a character
which exists in the varchar/char datatype whole format will get disturbed.
comma seperated file is a good example for this.
Also point to be noted that if any of the char/varchar field contains TAB
character even this file's format will get disturbed.
you can also run above command line using xp_cmdshell and thus can be used
in T-SQL script.
exec master..xp_cmdshell 'bcp "select * from northwind..orders" queryout
c:\cust.xls -c -S<server> -Usa -P'
"shank" <shanktampabay.rr.com> wrote in message
news:#fo2ePWQDHA.1988TK2MSFTNGP12.phx.gbl...> How can I use SQL to create an excel spreadsheet? We have lists online and
> depending on what a user selects, I'd like the date dumped into an *.XLS
> file that they can download.
> What's the process on something like that?