Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help calling sproc1 with parameter from sproc2

Author  Topic 

delbar
Starting Member

5 Posts

Posted - 2009-11-17 : 04:44:25
I have to call a sproc that has a parameter and returns a result set from sproc2 - I will need to reference the parameter from sproc1. How is this done? Do I need to set my own variable or param and set it to the param i the first sproc?

Please help - have never worked with this and can't seem to figure this out.

thanks,
delbar

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-11-17 : 11:15:43
Not really sure what you're asking. But the simple interpretation is:


--SP1
declare @localVar int
set @localVal = 10

exec SP2 @parameter1 = @localVar

now both SPs have access to the same value (SP1-@localVar; SP2-@parameter1)

Or perhaps you need to set the value in SP2 and then use it in SP1. In that case you need to use an OUTPUT parameter:

declare @localVar int

exec SP2 @parameter1 = @localVar OUTPUT --SP2 @parameter1 is defined with OUTPUT as well
select @localVar as [ValueSetInSP2]


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -