您的位置:首页 > 数据库

SQL Server 触发器的删除操作

2012-02-19 12:38 295 查看
有两表: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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐