2008 SQL Stored Procedure output to a pre-existing Excel 2003 spreadsheet

  • 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.

  • 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.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • 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.

  • Using Powershell you can query SQL Server and create rich excel sheets with the data.

    http://www.petri.co.il/export-to-excel-with-powershell.htm

    http://blogs.msdn.com/b/buckwoody/archive/2009/11/09/create-an-excel-graph-of-your-big-tables-with-powershell.aspx

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply