Groups | Blog | Home
all groups > sql server programming > february 2007 >

sql server programming : saving result into an excel file from query string



jack
2/18/2007 8:19:36 PM
Hi all


I want to save the result derived by execution of query or proc into a
excel file along with the column name. this can be done by right
clicking on the query panel of the result set, But can this be done
via query string..

Thanks for answering me..
EMartinez
2/18/2007 9:45:11 PM
[quoted text, click to view]

A common way of doing this is via DTS package. You can insert the
results into a table and create a DTS package to export the results
(incl. column names) to an Excel file. Then use the following to call
the DTS package, from the stored procedure, at the command line:
exec xp_cmdshell 'dtsrun /S SQLServerName /U UserName /P Password /N
DTSPackageName'

Hope this helps.

Regards,

Enrique Martinez
Sr. SQL Server Developer
lucky
2/18/2007 11:37:40 PM
[quoted text, click to view]
work for you.

Open Excel --> Data --> Import External Data --> Database Query

Thanks
-Mahesh
AddThis Social Bookmark Button