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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 define an sp inside another sp?

Author  Topic 

johnsql
Posting Yak Master

161 Posts

Posted - 2006-04-19 : 13:53:23
Is it possible to do the following?

Assume I have a big stored procedure (sp) sp_A, and a sub sp sp_B. Sp sp_B is used more than 1 time in sp sp_A. Istead of define and compile sp sp_B in a separate physical file on hard disk, I'd like to define and use it inside the body of sp sp_A like:

create procedure dbo.sp_A
as
-- start of sp_A ------------------------
...
-- use sp_B to do things
exec sp_B
...
-- use sp_B to do things
insert #t
exec sp_B

-- now to define sp_B inside the body of sp_A
-- create and then alter sp_B:
alter procedure dbo.ap_B
as
-- define sp_B
...
...

-- end of sp_A ------------------------
GO

Thanks for your ideas.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-04-19 : 13:54:47
You can't define a stored procedure inside another stored procedure, but you can execute other stored procedures in one. Stored procedures aren't separate physical files on your hard disk. They are simply a row in the syscomments table in your user database.

Tara Kizer
aka tduggan
Go to Top of Page

a_r_satish
Yak Posting Veteran

84 Posts

Posted - 2006-04-20 : 00:51:33
Hey. may i know, what for you have such a requirement.

Create them seperately and use them as nested when executing...

satish.r
"Way to success is always under Construction"
Go to Top of Page
   

- Advertisement -