create proc meproc as begin declare @str varchar(8000) select * from stu if exists(select 1 from dbo.sysobjects where id = object_id(N'mytest') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop proc mytest select @str=' create proc mytest as select * from subject' print @str exec(@str) endexec meproc exec mytest
create proc xbxb as exec('create proc xxxx as select * from a' )
as
begin
declare @str varchar(8000)
select * from stu
if exists(select 1 from dbo.sysobjects where id = object_id(N'mytest') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop proc mytest
select @str='
create proc mytest
as
select * from subject'
print @str
exec(@str)
endexec meproc
exec mytest
as
exec('create proc xxxx
as
select * from a'
)