UPDATE() function in Trigger will is one of the very useful function related to trigger. UPDATE() function will help you to know that which column is going to update. Let us see how will it work?
–create table1 for demo
CREATE TABLE CustInfo
CustId INT Identity(1,1),
–insert records in above table
INSERT INTO CustInfo
SELECT ‘RITSEH’,’India’ UNION ALL
SELECT ‘RAJAN’ ,’Hindustan’
–CREATE trigger to check which field
–we are updating
CREATE TRIGGER UpdateCheck ON CustInfo
PRINT ‘YOU HAVE UPDATED NAME FIELD’
PRINT ‘YOU HAVE NOT UPDATED NAME FIELD’
–check this out
UPDATE CustInfo SET Name =‘R.Shah’ WHERE Name=‘RAJAN’
As we are updating Name field, we will see first message as condition will fall in IF part.