触发器中获取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