Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql to detect fields modified in update trigger ( sql server 2005 )?

In sql server 2005 , inside an update trigger is there a way to find the list of fields\columns those are modified by the original update query.

I have a table with 150 columns and inside the trigger need to konw if ONLY one particular field was updated or not ( and no-other field was modified )

I can write a long sql to compare 150 columns but it will be error prone and look stupid!

Any decent way of getting around this problem. I am hoping some sql2005 api will come to my rescue.

like image 839
dotnetcoder Avatar asked May 26 '26 11:05

dotnetcoder


1 Answers

Take a looksie at COLUMNS_UPDATED - it's a bit of a pain, but you should be able to work with it quite easily for your requirement. There's a decent article about it on SQL Server Central.

like image 129
Steven Robbins Avatar answered May 30 '26 07:05

Steven Robbins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!