在表authors中建立触发器
create trigger trigName on authors
for update
as
if updte(au_id)
begin
update titleauthor ..
from deleted as d
where d.au_id=titleauthor.au_id
..............
where
end
go
create trigger trigName on authors
for update
as
if updte(au_id)
begin
update titleauthor ..
from deleted as d
where d.au_id=titleauthor.au_id
..............
where
end
go
for update
as
if (select count(*) from inserted)>1
begin
raiserror('对不起,不能同时更新多条记录,因为没有自增列,更新前后的记录无法对应!',16,1)
rollback tran
end
if update(au_id)
update titleauthor set au_id=(select au_id from inserted)