467,134 Members | 947 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,134 developers. It's quick & easy.

How to Pass Parameters from SQL Server Stored Procedure to Excel

Hi,
I am new to Excel programming, can you please explain how can I pass the parameters of SQL SP to excel.
If I am not having any parameters I am using EXEC <SP Name> using new database query in Excel - it works.
Now I am having 2 parameters, how can I do that?
I am trying to use: EXEC <SP name> @param1, @param2, but it is giving error.
appreciate your help
Sep 9 '08 #1
  • viewed: 14869
Share:
5 Replies
ck9663
Expert 2GB
A little confusing.

Where are you running the SP? Your question is about passing parameters from SQL Server to Excel, yet you called your SP from excel.

If you are running it from excel and wants to execute an SP, you can build the EXEC as string with all the parameters that you need. Don't forget the quotes.

-- CK
Sep 9 '08 #2
A little confusing.

Where are you running the SP? Your question is about passing parameters from SQL Server to Excel, yet you called your SP from excel.

If you are running it from excel and wants to execute an SP, you can build the EXEC as string with all the parameters that you need. Don't forget the quotes.

-- CK
Sorry for confusing.

I want the data in excel, pulled from SQL server stored procedure. The SQL SP has the parameters.
when I open/refresh the excel it should prompt the user to enter the parameters (dynamically), and depending on the parameters the relavent data should be populated in excel. thank you
Sep 9 '08 #3
ck9663
Expert 2GB
That's more of an EXCEL/VBA question than a sql server question. I would assume you will need to create a form or use excel's INPUTBOX function. Then from there you can dynamically build your SQL string.

Here's how you call stored procedure in SQL Server.

-- CK
Sep 9 '08 #4
That's more of an EXCEL/VBA question than a sql server question. I would assume you will need to create a form or use excel's INPUTBOX function. Then from there you can dynamically build your SQL string.

Here's how you call stored procedure in SQL Server.

-- CK
Thank you very much, I wil try and let you know
Sep 10 '08 #5
There is a method using a DSN connection the sytax is {call [procname](?,?)} add ?'s for extra parms. You can reference cells in the Excel sheet. To get to this, Import External Data, New Database Query, then click through any table from the DB the the Proc lives, then view query and click on the SQL button in ms Query, then simply enter the above in place of what ever SQL is there.
Nov 11 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Niyazi | last post: by
2 posts views Thread by honcho | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.