3

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.

Cade Roux
  • 88,164
  • 40
  • 182
  • 265
dotnetcoder
  • 3,431
  • 9
  • 54
  • 80
  • Take a look at this answer https://stackoverflow.com/a/8020461/350188, it's well suited to picking out a few fields in a larger table. It's also less painful than using columns_updated – Stephen Turner Jun 27 '19 at 11:23

1 Answers1

10

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.

Steven Robbins
  • 26,441
  • 7
  • 76
  • 90