有没有办法知道表上的更新是由ON UPDATE CASCADE而不是通过任何其他方法进行的?
create table systems (system nvarchar(10))
go
create table subsystems (system nvarchar(10), subsystem nvarchar(10))
go
-- adding foreign key with cascade update
create trigger subsystems_utrig
on subsystems
for update
as
if update (system) -- should be checking for cascade update
begin
-- raiserror ('cascade update not allowed',18,1) rollback transaction
-- insert something in the log table
return
end
go
insert into systems (system)
select 'first system'
go
insert into subsystems (system, subsystem)
select system, 'sub' + system
from systems
go
update systems
set system = 'new system'
where system = 'first system'
go
因此,在更新语句之后,级联应该工作并且子系统的更新触发器触发。 有没有想过这个?
谢谢!