USE [Yolo880_Hotel] GO /****** Object: Trigger [dbo].[change_EndDateTime] Script Date: 2023-01-30 14:52:05 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create trigger [dbo].[change_EndDateTime] on [dbo].[T_RoomOrder] AFTER INSERT AS BEGIN Declare @Status varchar(10); --房间状态 Declare @fid varchar(10); --房间客单号 Declare @KeyId varchar(10); --房间号 Select @Status=F_Status from inserted; if (@Status ='入住') begin INSERT INTO dbo.T_Log_RoomSvrc ( F_EventType , F_Content, F_Username, F_TableName, F_Table_FID ) SELECT '记录离店日期','房号:'+F_KeyId + ' ,操作员:' + F_OperationId +' ,超时时间:' +CONVERT(varchar(100), F_DateTimeTxt, 20)+ ' ,离店日期:' +CONVERT(varchar(100), F_EndDateTime, 20) ,F_OperationId ,'T_RoomOrder',f_id FROM inserted end END