触发器中获取sql

CREATE trigger 触发器名
on 表名
for update,delete
as
set nocount on
create table #t(EvebtType varchar(60),Parameters int,EventInfo varchar(2000))
declare @id varchar(20)
set @id=@@spid
insert #t
exec('DBCC INPUTBUFFER ('+@id+')')

if exists (select 1 from #t where EventInfo not like '%where%')
BEGIN
RAISERROR ('删除、修改语句必须写where部分',16, 1)
ROLLBACK TRANSACTION
END

 

posted @ 2021-11-12 15:33  212的s  阅读(112)  评论(0编辑  收藏  举报