SQL Server 触发器的删除操作
有两表:Blog,Comment。Comment表中的CommentBlog是Blog表中主键Id的外键。
删除Blog表中数据时,要求Comment表中对应Id外间所在的数据同时删除。
编写触发器:
create trigger BlogDelet
on Blog
instead of delete
as
delete from Comment
where CommentBlog in (select Id from deleted)
有两表:Blog,Comment。Comment表中的CommentBlog是Blog表中主键Id的外键。
删除Blog表中数据时,要求Comment表中对应Id外间所在的数据同时删除。
编写触发器:
create trigger BlogDelet
on Blog
instead of delete
as
delete from Comment
where CommentBlog in (select Id from deleted)