Link to home
Start Free TrialLog in
Avatar of rmaranhao
rmaranhao

asked on

How to determine witch column was updated during a trigger if the COLUMNS_UPDATED() is larger then the integer value

I have a trigger that runs after update on a table.

Microsoft tells that the way to determine witch column was modified is to use

IF COLUMNS_UPDATED() & ColumnNumber > 0 . My problem is that due to the number of columns on this table the ColumnNumber is 8589934592. This number is bigger than the integer value and if I cast it as a BigInt the bitwise operator & does not work.

Does anybody now a way around this?

Thanks in advance,
Roberto.
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmaranhao
rmaranhao

ASKER

For the question log:

An easy way to determine the " power(2, (n-1)) "  value is to print the SUBSTRING(COLUMNS_UPDATED(),n,1 and then convert this hexadecimal value to decimal and then work from there...

The code would look loke this:

IF (SUBSTRING(COLUMNS_UPDATED(),1,1)=20) --  Columns 3 and 5 (2^2 + 2^4)
     
      AND (SUBSTRING(COLUMNS_UPDATED(),2,1)=1) -- Column 9   (Second group, 2^0)
      )


I think it's easier to read this way.