批量更新触发器问题?
触发器:当更新的数据COL004字段为NULL时,不更新,保留更新前的值。单个测试没问题
但批量更新的时候DELETED表保存了所有更新前的数据。求解!
CREATE TRIGGER tri_update_fax ON [dbo].[test]
FOR UPDATE
AS
declare @old_text varchar(50)
declare @new_text varchar(50)
select @old_text=col004 from deleted
select @new_text=col004 from test where col001=(select col001 from deleted)
if @new_text is null
begin
update test set col004=@old_text where col001=(select col001 from deleted)
end