22,210
社区成员
发帖
与我相关
我的任务
分享
if object_id('tgr_t1', 'tr') is not null
drop trigger tgr_t1
go
create trigger tgr_t1
on t1
for insert,update
as
declare @id int, @col1 nvarchar(128), @col2 nvarchar(128), @col3 nvarchar(128);
select @id=id,@col1 = col1, @col2 = col2, @col3 = col3 from inserted;
if @col1=N'指定值1'
update t1 set col1=null where id=@id
if @col2=N'指定值2'
update t1 set col2=null where id=@id
if @col3=N'指定值1'
update t1 set col3=null where id=@id
go