June 5, 2013 at 9:47 am
I want to create a stored procedure where the output will to into an Excel spreadsheet that will have a Header.
I am using SQL 2008 and Excel 2003.
Thank you.
June 6, 2013 at 2:58 am
You can do it in few ways.
Create vb or javascript which will connect to database, execute your procedure and output its results into existing Excel document or you can write VB module in Excel itself which will do exactly the same. The last one probably will need to be created as macro in one of Execl templates.
June 6, 2013 at 6:48 am
You could also use MSQuery via the Data Import menu from within Excel 2003. First create a simple select query to create link to destination cells, then edit the query by deleting the 1st query in the SQL box and inserting something like the following and return results to Excel (you will be prompted for parameters):
{call scheme.sp_drdays (?,?,?,?)}
Outer {} and inner() brackets are necessary parts of syntax.
The 1st part is procedure name, followed by input parameters within brackets(?) and separated by commas for each parameter. If there are no input parameters then use empty brackets: {call procname()}. Parameters can be linked to worksheet cells and query can be refreshed with any change in parameter values. When using date parameters first format input cells as text and use yyyy/mm/dd to input dates.
June 11, 2013 at 2:37 am
Using Powershell you can query SQL Server and create rich excel sheets with the data.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply