USE [Yolo880_Hotel] GO /****** Object: Trigger [dbo].[double_room] Script Date: 2024-01-20 09:29:26 避免同一个房间短时间内换房多次 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create TRIGGER [dbo].[Update_Status] ON [dbo].[T_RoomOrder] AFTER UPDATE AS DECLARE @old_status varchar(10), @new_status varchar(10); SELECT @new_status=F_Status FROM inserted i; SELECT @old_status=F_Status FROM deleted d; if UPDATE(F_Status) BEGIN if @old_status = '已换房' and @new_status ='已换房' BEGIN ROLLBACK; END END