CREATE TRIGGER [dbo].[t_MyCoolTrigger] ON [dbo].[MyCoolTable]
FOR INSERT, UPDATE, DELETE AS
BEGIN
SET NOCOUNT ON
IF (EXISTS(SELECT * FROM DELETED) AND (COLUMNS_UPDATED() = 0x0)) PRINT 'DELETE'
IF (EXISTS(SELECT * FROM DELETED) AND (COLUMNS_UPDATED() <> 0x0) AND EXISTS(SELECT * FROM INSERTED)) PRINT 'UPDATE'
IF (NOT EXISTS(SELECT * FROM DELETED) AND EXISTS(SELECT * FROM INSERTED)) PRINT 'INSERT'
END
|