Off-topic Talk Where overpaid, underworked S2000 owners waste the worst part of their days before the drive home. This forum is for general chit chat and discussions not covered by the other off-topic forums.

SQL question?

Thread Tools
 
Old Apr 12, 2007 | 02:23 PM
  #1  
stockae92's Avatar
Thread Starter
Registered User
 
Joined: Nov 2001
Posts: 6,006
Likes: 0
From: socal
Default SQL question?

how (or is there a way) to execute store procedure inside another store procedure?

i.e.

create procedure [sp_1]

as

-- execute a store procedure sp_2 here
-- and grab the result of the sp_2

go
Reply
Old Apr 12, 2007 | 03:09 PM
  #2  
Liebernoodle's Avatar
Registered User
 
Joined: May 2001
Posts: 1,260
Likes: 0
From: Tree Town
Default

I believe you can just use the "EXEC" command to "exec"ecute another stored procedure:

Create procedure dbo.sp_1
AS

DECLARE @meh INT

SET @meh = EXEC dbo.sp_2

GO

something like that. Assuming of course sp_2 returned an int. It can be whatever obviously.
Reply
Old Apr 12, 2007 | 03:15 PM
  #3  
stockae92's Avatar
Thread Starter
Registered User
 
Joined: Nov 2001
Posts: 6,006
Likes: 0
From: socal
Default

thanks so much

i did this and it seems to be working


Create procedure dbo.sp_1
AS

DECLARE @meh INT

EXEC dbo.sp_2
@sp_2_output = @meh output -- @sp_2_output is declared as output in sp_2

GO
Reply
Old Apr 12, 2007 | 03:17 PM
  #4  
Liebernoodle's Avatar
Registered User
 
Joined: May 2001
Posts: 1,260
Likes: 0
From: Tree Town
Default

Reply
Old Apr 12, 2007 | 03:19 PM
  #5  
stockae92's Avatar
Thread Starter
Registered User
 
Joined: Nov 2001
Posts: 6,006
Likes: 0
From: socal
Default

thanks for the quick help
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
The Unabageler
The Corner
17
Jul 14, 2020 12:10 PM
esoteric
The Corner
28
Apr 9, 2006 07:12 PM
The Raptor
The Corner
3
Dec 24, 2004 06:42 AM
DR. JEKYLL
Off-topic Talk
0
Jan 7, 2003 09:18 PM




All times are GMT -8. The time now is 07:56 PM.