OLEDB - INSERT INTO Excel FROM Stored Procedure

D

DevInstinct

Is it possible to insert data in Excel from a *Stored Procedure* using
OLE-DB?

I use something like:
INSERT INTO [Sheet12$] SELECT * FROM [odbc;Driver={SQL
Server};Server=blabla;Database=Northwind;User
ID=bla;Password=bla].Orders

I'd like to use something like:
INSERT INTO [Sheet12$] EXECUTE [odbc;Driver={SQL
Server};Server=blabla;Database=Northwind;User
ID=bla;Password=bla].GetOrdersProc()

Thanks
 
D

David Lloyd

One alternative is to use ADO to connect to the SQL Server database, create
a recordset based on the stored procedure, and then use the
CopyFromRecordset method to insert the data in Excel. The Execute method of
the ADO connection object allows you to specify a SQL Server stored
procedure. The following KB articles provide more information.

http://support.microsoft.com/default.aspx?scid=kb;en-us;306125
http://support.microsoft.com/default.aspx?scid=kb;en-us;247412

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


Is it possible to insert data in Excel from a *Stored Procedure* using
OLE-DB?

I use something like:
INSERT INTO [Sheet12$] SELECT * FROM [odbc;Driver={SQL
Server};Server=blabla;Database=Northwind;User
ID=bla;Password=bla].Orders

I'd like to use something like:
INSERT INTO [Sheet12$] EXECUTE [odbc;Driver={SQL
Server};Server=blabla;Database=Northwind;User
ID=bla;Password=bla].GetOrdersProc()

Thanks
 
D

DevInstinct

Thanks, but I need to run this server-side. Using automation is not an
option. I can do with the select. I just want to know if there's a way
WITH OLE-DB to call a stored proc in the same manner I call the select.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top