USE Northwind;
GO
IF OBJECT_ID ('TableUpdateTrigger','TR') IS NOT NULL
DROP TRIGGER TableUpdateTrigger;
GO
CREATE TRIGGER TableUpdateTrigger
ON Categories
AFTER INSERT, UPDATE, DELETE
AS
IF NOT EXISTS (SELECT * FROM zzzTableUpdates WHERE TableName='Categories')
INSERT INTO zzzTableUpdates (TableName, LastUpdate) Values ('Categories', GETDATE())
ELSE
UPDATE zzzTableUpdates SET LastUpdate=GETDATE() WHERE TableName='Categories'
GO
No comments:
Post a Comment