I need to 'pull' the results of an SQL stored procedure (returns a table) into Excel. Can someone point me in the right direction? SQL 2005 * Excel 2003 SP2.
you can use a standard ADO Recordset to return the output of the SP into Excel.
This is probably better asked on the VBA forum, but in any case you will need to add a reference to MDAC 2.x (2.8 or greater if possible), and then you can use a ADO command object associated with a ADO recordset object to execute and retrieve the SP results.
Depending on your version of Excel you may have a "copyfromrecordset" method from within Excel. If you dont then you can just loop normally through the recordset.
Unless you are a total query novice, I'd discard the stored procedure that would return an entire table.
Rather query your SQL Server directly via MA Query -- Data/Get External Data... Return ONLY the subset of data that you really need. Add parameters to return different resordset.
Once you have added a QueryTable to an Excel sheet, all you need do is Data/Refresh Data
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.