---------BEGIN----------- -------****1、创建触发器tri_RestrictXK************* GO -------****2、创建触发器tri_UpdateTeacher*************
时间: 2024-06-02 21:05:37 浏览: 161
这是两个 SQL Server 数据库触发器的创建语句,请参考:
1. 创建触发器tri_RestrictXK:
CREATE TRIGGER tri_RestrictXK
ON dbo.Student
FOR INSERT, UPDATE
AS
BEGIN
IF EXISTS (SELECT 1 FROM inserted WHERE XKScore < 60)
BEGIN
RAISERROR('XKScore should be greater than or equal to 60', 16, 1)
ROLLBACK TRANSACTION
END
END
GO
2. 创建触发器tri_UpdateTeacher:
CREATE TRIGGER tri_UpdateTeacher
ON dbo.Teacher
FOR UPDATE
AS
BEGIN
IF UPDATE (Name)
BEGIN
RAISERROR('You cannot update Name of Teacher', 16, 1)
ROLLBACK TRANSACTION
END
END
GO
阅读全文