[SQL]声明触发器 <待整理>

5./*声明触发器
create trigger dl_stu_mess4 on student for delete
as
declare @name_id int
select @name_id=stu.name from student stu,deleted d where stu.name=d.name
if exists(select * from books where books.name=@name_id)
delete from books where books.name=@name_id
print ‘jhsdjkjk‘
print @name_id
*/
/*
create trigger dl_stu_mess3 on books for delete
as
declare @name_id int
select @name_id=bo.name from books bo,deleted d where bo.name=d.name
if exists(select * from student where student.name=@name_id)
delete from student where student.name=@name_id
print ‘jhsdjkjk‘
print @name_id
*/
--sp_depends books 查看触发器
--sp_helptrigger student; 查看触发器信息
--drop trigger dl_stu_mess4; 删除触发器
insert into student values(2,4jkjjk,d,j,shs);
--delete from student where stu.name=2; 删除操作
select * from student;
--delete from books where books.name=2
--select * from books;

[SQL]声明触发器 <待整理>,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。