Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Ratz03
Starting Member
27 Posts |
Posted - 2015-01-14 : 09:15:43
|
Hi Experts,Could you please help me in writing a piece of code for stored procedure to export query results to an excel sheet.Thankyou |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-01-14 : 09:44:40
|
Easier to use SSIS. All you need is built-in |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2015-01-19 : 01:40:14
|
@Ratz03 - another method to think about depending on your requirements , is to use Powershell.In the example,a connection is made to a SQL server Instance , a recordset is returned , placed into a DataSet and then written to a new Excel worksheethttp://www.sqlserver-dba.com/2013/05/sql-server-export-to-excel-with-powershell.htmlJack Vamvas--------------------http://www.sqlserver-dba.com |
|
|
Ratz03
Starting Member
27 Posts |
Posted - 2015-01-19 : 11:32:12
|
Thankyou jackv. Powershell looked complicated as i'm a newbie with SQL.@gbritton: I used SSIS package and was able to export my query results to a excel. However, what the query returns is a report which is monthly. Is there a way using SSIS package where file is created eachtime with the date in the file name at the same location.Also, it is feasible to have 2 queries returning data on different tabs of xcel. This is the requirement for my report.Many Thanks. |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-01-19 : 12:02:44
|
" Is there a way using SSIS package where file is created eachtime with the date in the file name at the same location."Yes -- on the Excel file connector propertieds, you can set the filename to be an expression that you build up the way you want." it is feasible to have 2 queries returning data on different tabs of xcel. This is the requirement for my report."Yup -- I do it all the time. You use two data flow tasks. |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
|
|
|
|