sql触发器

作者在 2010-06-22 20:38:40 发布以下内容
USE [Students]
GO
/****** 对象:  Trigger [del_stu1]    脚本日期: 06/22/2010 20:36:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create trigger [del_stu1] on [dbo].[学生表]
for delete
as
declare @xuehao int
select @xuehao=学号 from Deleted
if exists(select *from 课程注册表 where 学号=@xuehao)
  begin
print '不能将其删除'
rollback transaction
end
sql | 阅读 574 次
文章评论,共0条
游客请输入验证码