if update

i see the below segment in the update trigger..

does it mean if  payslip_code column is updated in the original update statement, then the below segment will be executed? (if other columns are updates, then the below segment will not be executed?)
if update(payslip_code)  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yep u got it right.

whichever table its set on, the code says - if column payslip_code is updated then run the code below.

payslip_code has to be updated to run this code, other columns won't execute the code
Anthony PerkinsCommented:
Actually no.  You cannot infer that the data was actually modified (otherwise the clause may have been called IF UPDATED() and not IF UPDATE() ).  What it does do is tell you that the column participated in UPDATE statement.  The only true way to discover if the data has actually  changed is by comparing the values in the columns of the DELETED and INSERTED logical tables.
Anthony PerkinsCommented:
But don't take my word for it, do something like this:
UPDATE YourTableName
SET YourColumn = YourColumn
WHERE SomeConditionGoesHere

And you will see that the IF UPDATE() is true, even though the value obviously did not change.  Yes, I do realize this example is silly, but I hope you get my drift.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
if UPDATE(column name) will tell you if "at least" that column was part of the UPDATE ... SET column_name = <expression>
as indicated by acperkins: it will NOT tell you if the value actually changed !
Anthony PerkinsCommented:
>>as indicated by acperkins: it will NOT tell you if the value actually changed !<<
And I will confess I learned that from you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
25112Author Commented:
so what the first expert said was partially true..

what angel and acp have confirmed is that: IF that column was at least a part of that update.. are you meaning it was one of the SET columns.. not in the FROM or WHERE part, right?
Anthony PerkinsCommented:
Do you have access to SQL Server's BOL.  This is what it has to say about IF UPDATE()
The UPDATE() function can be used to determine if an INSERT or UPDATE statement affected a specific column in the table. The function returns TRUE whenever the column is assigned a value.
Alternatively, the COLUMNS_UPDATED function can be used to check which columns in a table were updated by an INSERT or UPDATE statement. This function uses an integer bitmask to specify the columns to test. For more information, see CREATE TRIGGER.

25112Author Commented:

i better install it also.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.