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
 Calling a stored proc from another stored proc

Author  Topic 

allanurban
Starting Member

21 Posts

Posted - 2012-08-24 : 06:16:35
Hello

I have a store procedure (GetLimits) with a single input variable (stat varchar). It returns a resultset with a single row and three columns (col1 int, col2 float, col3 bit).

col1 and col2 holds some limits that I need in calculating my output in a second stored procedure called GetOutput with the same input variable as GetLimits.

I can execute the first one with:
EXEC GetLimits 'Stat1'

But how can I then use the resultset I get? Can I save the resultset into variables and then work with them?

I'd really appriciate a small nod in the right direction.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-08-24 : 06:43:52
declare a table variable (or temp table) with the correct format then

insert @tbl
exec GetLimits 'Stat1'



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

allanurban
Starting Member

21 Posts

Posted - 2012-08-24 : 07:34:43
Exactly what I needed. Thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-24 : 10:02:54
quote:
Originally posted by allanurban

Exactly what I needed. Thanks.


there's one more way of doing this though not a preffered one

see

http://beyondrelational.com/modules/2/blogs/70/posts/10812/select-columns-from-exec-procedurename-is-this-possible.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -