码迷,mamicode.com
首页 > 数据库 > 详细

sql-server数据库中利用触发器实现表与表之间的级联删除

时间:2015-07-04 22:13:23      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

create trigger Delete_Student --创建一个触发器
on student 
instead of delete 
as
  declare @sno varchar(20)  
  select @sno= sno from  deleted
  delete from score  where sno=@sno
  delete from student where sno=@sno
go 
 delete from Student where Sno=101
 select *from Student 
 select *from Score 

 

sql-server数据库中利用触发器实现表与表之间的级联删除

标签:

原文地址:http://www.cnblogs.com/kangshuai/p/4621290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!