p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Server 2000 (http://p2p.wrox.com/forumdisplay.php?f=20)
-   -   SQL Pass though parameters to stored procedures (http://p2p.wrox.com/showthread.php?t=11121)

blinton25 March 29th, 2004 09:26 AM

SQL Pass though parameters to stored procedures
 
Hello,

How are you today?

I need to pass parameters from an Access front end form to a Stored Procedure. I found a method of doing this:

http://p2p.wrox.com/post.asp?method=Topic&FORUM_ID=5

My challenge is that the stored procedure is not called directly, instead I use this query:

SELECT regionorder, Regions3, 1 As Quarter, January as A, February as B, March as C FROM RegionofResidenceCrosstab
UNION ALL
SELECT regionorder, Regions3, 2 As Quarter, April, May, June FROM RegionofResidenceCrosstab
UNION ALL
SELECT regionorder, Regions3, 3 As Quarter, July, August, September FROM RegionofResidenceCrosstab
UNION ALL SELECT regionorder, Regions3, 4 As Quarter, October, November, December FROM RegionofResidenceCrosstab;

and the Union query then calls the crosstab query which needs the parameters that are passed. Can a stored procedure call another stored procedure and pass parameters to it, and if so, how can this be done?

bmains March 29th, 2004 10:04 AM

A stored procedure can call another stored procedure, such as:

set @rs = exec newsp @param1, @param2, ... etc

The exec method executes stored procedures within the stored procedures.

blinton25 March 29th, 2004 10:31 AM

Hello,

Thanks for the response.

Not sure how/if I can exec and pass parameters using Union. Remember RegionofResidenceCrosstab is my stored procedure.

Or to ask a different way, can I select from the results of a stored procedure?

bmains March 29th, 2004 02:49 PM

You may be able to select the results of the SP, or do:

set @rs = exec new sp ...

select ..., @rs... etc.


All times are GMT -4. The time now is 02:14 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.