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'
去
On INSERT
, UPDATE
, DELETE
trigger 可以工作 但是如何让它在 select 语句上或之前工作