Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
aploessl
Starting Member
1 Post |
Posted - 2006-01-17 : 17:12:27
|
| 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) > 0Am 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 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-01-17 : 21:10:05
|
| Just so it's clear, you know a trigger for update will always fire on an update. Your IF block should control the flow if execution assuming the condition is correct.Now assuming you realize that, the problem is you need to perform a seperate bitwise comparison for each set of 8 columns. In other words columns 1-8 will be reflected in the substring: substring(columns_updated(), 1,1) for columns 9-16: substring(columns_updated, 2,1) etc...What you are comparing to is the bitmask of 0 through 8 to the power of 2. so column1 is 1, column9 is also 1.I am on vacation so I can't provide a working (tested) sample. I hope that is clear enough.Be One with the OptimizerTG |
 |
|
|
|
|
|