October 23, 2002 04:23 PM

Calling a Stored Procedure from Another Stored Procedure

Rating: (0)
SQL Server Magazine
InstantDoc ID #26615

I want stored procedure A to call stored procedure B, which returns a set of records from a table. Then, I want stored procedure A to perform work on these records. How do I call stored procedure B from within stored procedure A?

In releases earlier than SQL Server 2000, you can call one stored procedure from another and return a set of records by creating a temporary table into which the called stored procedure (B) can insert its results or by exploring the use of CURSOR varia...

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

answer 05 january 2005 - rating 5 !!!

Anonymous User 7/13/2005 2:04:25 AM


My case is, I have a SP A in Server-1, and I want to call it from SP B in Server-2. This Server-1 is not registered in Server-2. Hope I'm clear. I'll be greatful if somebody can suggest me a way out. Can contact me at gvlprasad@gmail.com

Thanks a lot.

Anonymous User 6/3/2005 1:48:09 AM


Horible article -- doesn't answer the question at all!

Anonymous User 6/1/2005 4:45:34 PM


That is bloody fantastic! You do rock!!

Anonymous User 5/9/2005 9:27:28 PM


That's awesome. You Rock.

Anonymous User 2/11/2005 12:56:11 PM


Try this:
CREATE TABLE #locks (spid int, dbid int, objid int, objectname sysname NULL,
indid int, type char(4), resource char(15), mode char(10), status char(6))
INSERT #locks (spid, dbid, objid, indid, type, resource, mode, status)
EXEC dbo.sp_lock
SELECT * FROM #locks
DROP TABLE #locks

Anonymous User 1/5/2005 4:43:50 AM


Is this possible? --
Pputting a result of Stored procedure (sp-1) into a temp table (#t) in a new Stored procedure (sp-new)

If yes, pls give SQL for this...

Anonymous User 1/4/2005 8:53:14 AM


Your Comments: :


Anonymous User 12/22/2004 9:43:38 PM


The question was: "How do I call stored procedure B from within stored procedure A?"

You provided a handy tip for the project he happens to be working on, but you didn't answer the question that he needed answered.

Anonymous User 12/7/2004 9:11:45 AM


I don't see how this shows you how to insert the results of one stored proc into another. The example is only using select statements? It doesn't really answer the question asked.

Yvonne Kaeder 3/19/2004 4:31:52 PM


You must log on before posting a comment.

Are you a new visitor? Register Here
GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS