September 25, 2002 05:25 PM

Identifying Modified Columns Puzzle

Rating: (0)
SQL Server Magazine
InstantDoc ID #26629
Your knowledge of bitwise operators can come in handy when you want to write a trigger to identify which columns an UPDATE statement modified. If you want to determine only whether a given column was updated, you can use the UPDATE() function. For example, if you want to see whether col3 was modified before you proceed with an activity, you simply use the following code:

IF UPDATE(col3)
BEGIN
  ...perform some activity...
END
How...

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

I am running SQL Server 2000 Professional sp 3 with copatibility level of 80, and your code produces an error:

select @COL = (COLUMNS_UPDATED(), 1, 1)


If I do

select @COL = (COLUMNS_UPDATED())

I don't get a syntax error, but I also don't get usable results.




thirdcoast 3/24/2005 4:15:59 PM


I like this approach a lot, but one thing.. how would you pull the new value based on this?

I have an app that is checking to see which field is updated, and when it does get updated, it runs a stored proc which writes to a tranlog..please help

Doug Degenaro 6/3/2004 8:42:21 AM


You must log on before posting a comment.

Are you a new visitor? Register Here
GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS