查数据库中所有包含了某个字符串的触发器的SQL语句
比如:查所有含有 GDMTL 的触发器:
set nocount on
Create table #y (Trname varchar(50),txt text)
select name, iid = identity(int,1,1) into #x from SysObjects where xtype = 'TR'
declare @i int, @max int
declare @name varchar(50)
set @i = 1
select @max = max(iid) from #x
while @i <= @max
begin
select @name = name from #x where iid = @i
insert #y (txt)
exec('sp_helptext ' + @name)
update #y
set [email protected]
where Trname is null
set @i = @i + 1
end
select * from #y where txt LIKE '%GDMTL%'
drop table #x
drop table #y
set nocount off