USE admin_gorace
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'trScheduler_Status_Update' AND type = 'TR')
DROP TRIGGER trScheduler_Status_Update
GO
CREATE TRIGGER trScheduler_Status_Update
ON [Client].[Scheduler]
FOR INSERT, UPDATE, DELETE , SELECT
AS
UPDATE [Client].[Scheduler] set [Status]='Over'
where (Convert(varchar,[Scheduler_Date],101) <=Convert(varchar,getutcdate(),101) or Convert(varchar,[Scheduler_Date],101) <= Convert(varchar,getdate(),101))
and (right(CONVERT( varchar, [time_to], 100),7)<= right(CONVERT( varchar, getutcdate(), 100),7) or right(CONVERT( varchar, [time_to], 100),7) <= right(CONVERT( varchar, getdate(), 100),7))
and [Status]!='Cancelled' and [Status]!='Over'
走
在INSERT
, UPDATE
, DELETE
触发器可以工作,但如何让它工作或SELECT语句前