Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to create trigger only when successful updatation of a column value happens. Expand / Collapse
Author
Message
Posted Thursday, December 03, 2009 3:45 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, May 11, 2011 3:40 AM
Points: 59, Visits: 15
CREATE TABLE TriggerTest (Value int)
GO
INSERT INTO TriggerTest VALUES (1)
GO

CREATE TRIGGER tr_TriggerTest ON TriggerTest
AFTER UPDATE AS
BEGIN
SET NOCOUNT ON;
[color=red]IF UPDATE(Value)
PRINT 'The trigger fired' [/color]
ELSE
PRINT 'The trigger did not fire'
END
GO

--Set Value equal to itself
UPDATE TriggerTest SET Value = Value
--SELECT * FROM TriggerTest
DROP TABLE TriggerTest


Post #828036
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse