January 17, 2006 at 3:36 pm
I am currently trying to implement update triggers on a table containing a total of 44 columns. I want to specify that the triggers should fire only when any of columns 1-15 are updated. Now I've tried to implement the columns_updated() statement within the trigger, but I must be screwing up the bitmask somewhere. The coniditional statement I used was:
IF (COLUMNS_UPDATED() & 32767) > 0
Am I making a miscalculation somewhere? Even when I update a column greater than 15 (like the end column), the trigger still fires...
HELP!
Thanks in advance
-A
January 17, 2006 at 3:58 pm
Hi,
I did not try it myself, but did you follow the example in
http://msdn2.microsoft.com/en-us/library/ms186329.aspx
It says in the middle after the first example:
To test for updates that affect columns other than the first eight columns in a table, use the SUBSTRING function to test the correct bit returned by COLUMNS_UPDATED
Then the example follows for the fields 3,5 9
.............
IF ( (SUBSTRING(COLUMNS_UPDATED(),1,1)=power(2,(3-1))
+ power(2,(5-1)))
AND (SUBSTRING(COLUMNS_UPDATED(),2,1)=power(2,(1-1)))
)
PRINT 'Columns 3, 5 and 9 updated';
It may be related that it is only 8 bits in a byte
Regards,Yelena Varsha
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply