Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 29th, 2004, 09:26 AM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
Reply With Quote
  #2 (permalink)  
Old March 29th, 2004, 10:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
Reply With Quote
  #3 (permalink)  
Old March 29th, 2004, 10:31 AM
Registered User
 
Join Date: Mar 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
Reply With Quote
  #4 (permalink)  
Old March 29th, 2004, 02:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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

set @rs = exec new sp ...

select ..., @rs... etc.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the SQL stored procedures BenCh BOOK: ASP.NET Website Programming Problem-Design-Solution 0 March 11th, 2005 04:18 PM
Calling Stored procedures with out parameters bansalh Access 1 November 25th, 2003 04:30 PM
Pass-through queries vs stored procedures kendawg Access 2 October 8th, 2003 02:00 AM
in-line parameters in stored procedures itekcorp ADO.NET 0 July 12th, 2003 09:57 PM



All times are GMT -4. The time now is 09:24 AM.


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