34,590
社区成员
发帖
与我相关
我的任务
分享
---用函数恐怕比较困难,用带返回的存储过程
Create procedure checkSQL
@sqlstr varchar(8000),
@Check tinyint output
as
create table #tmp(a int)
insert into #tmp
exec('select 1 where '+@sqlstr)
if exists(select 1 from #tmp)
select @Check=1
else select @Check=0
Go
declare @check tinyint
exec checkSQL '1=2',@check output
select @check
exec checkSQL '1=1',@check output
select @check
if exists(select 1 where 1=2)
return 'true'
esle
return 'false'