如何在SQL Server 2008中的另一个存储过程中创建存储过程

时间:2011-06-23 06:44:18

标签: sql sql-server-2008

我想创建一个存储过程,以便在存储过程中使用,如下所示。这可能吗?

CREATE procedure parentSP
as 

--child SP definition.
CREATE procedure childSP1 @inputArg varchar(50)
as 
--do something.
Go

--call child sp within parentSP
execute childSP1 '10'

Go

1 个答案:

答案 0 :(得分:10)

您可以使用exec:

CREATE procedure parentSP
as 
exec('CREATE procedure childSP1 @inputArg varchar(50)
as 
--do something.')

--call child sp within parentSP
execute childSP1 '10'
Go