如何避免级联触发?
有表两[db1.dbo.tb1] 和[db2.dbo.tb2] --在不同的库中
为了保证两表的某一字段相同。
所以写:
use db1
go
create TRIGGER tr_pwd_same_1 ON db1.dbo.tb1
FOR UPDATE
AS
if update(user_pwd)
update db2.dbo.tb2 set user_password = (select user_pwd from inserted) where user_id = (select user_base_id from inserted)
go
use db2
go
create TRIGGER tr_pwd_same_1 ON db2.dbo.tb2
FOR UPDATE
AS
if update(user_password)
update db1.dbo.tb1 set user_pwd= (select user_password from inserted) where user_base_id = (select user_id from inserted)
go