View Single Post
Old 01-09-2008, 12:30 PM   #2 (permalink)
Penio
Junior Member
 
Join Date: Jan 2008
Posts: 1
Default Re: run SQL stored procedure from Excel

You can assigned the following Sub to a button :


-------------------------------------------
Sub ExecuteStoredProcedure()

Dim Chan As Variant

'Open a channel to a SQL Server data source
Chan = SQLOpen("DSN=SQLServer")

'Execute the stored procedure "sp_who" and return the
'results to the activecell on the active sheet.
SQLExecQuery Chan, "Execute sp_who"

SQLRetrieve Chan, ActiveCell

'Terminate the channel
SQLClose Chan

End Sub

--------------------------------------------------------------

More info for SQL - Excel connection on:

Macro Examples Using XLODBC Functions

Cheers
Penio
Penio is offline   Reply With Quote
Sponsored Links