Identifying A Record from an On Update Trigger

I’ve created a trigger that checks to see whether a field has been updated by querying the status of the field ordinal Number with something like (03) & > 0 where 03 is my field ordinal.

I need to also read the updated record into a set of variables.

It is essential that I read the correct record as the field that is updated might not be unique.

How can I achieve this?
IT GuyDir of ITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Vitor MontalvãoMSSQL Senior EngineerCommented:
In a trigger you have access to the delete and insert tables where on the first one you have all the rows that has been delete and on the latter you have all the new rows. In an UPDATE operation you'll find rows in both tables.
You can also use the UPDATE() function in a trigger to check if a column has been changed or not.
So you'll need something like:
ON TableName
IF UPDATE (ColumnName) 
        -- Do here what you need to do if the column has been updated

Open in new window

IT GuyDir of ITAuthor Commented:
What I need to do it to be able to select the values of the entire record based upon one record having been updated.

I have my on update trigger, I have the ordinal of the column that has been updated - I just need a line and f code that will allow me to select the values from all fields that have been updated.

Do I select from deleted?
Vitor MontalvãoMSSQL Senior EngineerCommented:
You can select from the deleted and inserted tables, performing a comparison on the desired columns.

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
IT GuyDir of ITAuthor Commented:
I'll try it and let you know. Thank you.
IT GuyDir of ITAuthor Commented:
Worked - thank you
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

From novice to tech pro — start learning today.