if object_id('pro_test')is not null drop proc pro_test go create proc pro_test @tblname varchar(20) as declare @str varchar(200) set @str= 'if object_id('+quotename(@tblname,'''')+') is not null drop table '+@tblname print @str exec(@str)--TRY
if OBJECT_ID('test','P')is not null drop proc test go create proc test ( @table_name varchar(max) ) as declare @sql varchar(max) set @sql='' select @sql=@sql+'if object_id('+''''+@table_name+''''+') is not null drop table +'+@table_name+'+'+''exec (@sql)
if OBJECT_ID('test','P')is not null drop proc test go create proc test ( @table_name varchar(max) ) as declare @sql varchar(max) set @sql='' select @sql=@sql+'if object_id('+''''+@table_name+''''+') is not null drop table +'+@table_name+'+'+''exec (@sql)
if object_id('pro_test')is not null
drop proc pro_test
go
create proc pro_test @tblname varchar(20)
as
declare @str varchar(200)
set @str=
'if object_id('+quotename(@tblname,'''')+') is not null
drop table '+@tblname
print @str
exec(@str)--TRY
drop proc test
go
create proc test
(
@table_name varchar(max)
)
as
declare @sql varchar(max)
set @sql=''
select @sql=@sql+'if object_id('+''''+@table_name+''''+') is not null drop table +'+@table_name+'+'+''exec (@sql)
drop proc test
go
create proc test
(
@table_name varchar(max)
)
as
declare @sql varchar(max)
set @sql=''
select @sql=@sql+'if object_id('+''''+@table_name+''''+') is not null drop table +'+@table_name+'+'+''exec (@sql)