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)
删除Blog表中数据时,要求Comment表中对应Id外间所在的数据同时删除。
编写触发器:
create trigger BlogDelet
on Blog
instead of delete
as
delete from Comment
where CommentBlog in (select Id from deleted)
相关文章推荐
- SQL Server 触发器例题: --次性删除course表数据,使用触发器替换删除操作,先删除外键表相关数据,再删除course。很难理解
- 通过Delete触发器对数据进行删除操作
- [转]sql server 2000/2005 判断存储过程、触发器、视图是否存在并删除
- SQL SERVER 判断是否存在并删除某个数据库、表、视图、触发器、储存过程、函数
- 批量删除Sql Server对象(表,存储过程,触发器)
- sql server 2000/2005 判断存储过程、触发器、视图是否存在并删除
- SQL Server:触发器调用 - 存储过程递归删除父子类
- SQL SERVER的多行删除触发器use cursor
- sql server 2000/2005 判断存储过程、触发器、视图是否存在并删除
- 利用触发器对某个表的操作过程(删除、修改、插入)
- 数据库访问及其基本操作(sql server和添加删除查找替换)
- SQL SERVER 对数据库的一些基本操作:创建、更改、查看、删除……
- sql server 2000/2005 判断存储过程、触发器、视图是否存在并删除
- sql server ,oracle中触发器对同一个表进行触发操作。
- 对oracle当中子查询建表,merge操作,创建,修改,删除约束,创建使用触发器的复习练习
- 五.Sql server删除操作
- sql server 数据库中 触发器和约束的暂停及恢复操作 命令
- 使用触发器操作表1(添加,更新,删除) 同步实现表2的操作
- sql server 2000/2005/2008 判断存储过程、触发器、视图是否存在并删除
- sql server 数据库中 触发器和约束的暂停及恢复操作 命令