./*声明触发器
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(,'4jkjjk','d','j','shs');
--delete from student where stu.name=; 删除操作
select * from student;
--delete from books where books.name=''
--select * from books;
05-11 13:46