当您使用触发器对表运行 DELETE
语句时,该触发器中的 UPDATE( colName )
函数会返回 true 吗?
最佳答案
没有。 UPDATE(colName)
仅对于 INSERT 和 UPDATE 返回 TRUE
set nocount on
go
create table test ( cola nvarchar(10), colB int default(0) )
go
create trigger tr_test on test for insert,update,delete
as
begin
select case when update(cola) then 'yes' else 'no' end as ColA_Updated,
case when update(colb) then 'yes' else 'no' end as ColB_Updated
end
go
-- This outputs 'yes', 'yes'
insert into test (cola) values ( 'a' )
-- This outputs 'yes', 'no'
update test set cola = 'b'
-- This outputs 'no', 'no'
delete from test where 1=0
-- This outputs 'no', 'no'
delete from test
go
drop trigger tr_test
drop table test
go
关于sql-server - 当删除行时,SQL 触发器中的 UPDATED() 函数是否返回 true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29286034/