By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,265 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,265 IT Pros & Developers. It's quick & easy.

How to Pass Parameters from SQL Server Stored Procedure to Excel

P: 4
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
Share this Question
Share on Google+
5 Replies


ck9663
Expert 2.5K+
P: 2,878
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

P: 4
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 2.5K+
P: 2,878
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

P: 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

P: 2
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.