I am fairly new to the more advanced database features, such as functions, but I was curious how you would do this in MSSQL (or if it is possible even):
If I have a table and the structure is something like this:
t_test USR_VALUE MULTIPLIER TOLERANCE VALUE_OK 100 .8 85 OK 100 .9 85 NO
How would I get VALUE_OK to automatically update itself every time the row is updated depending on the USR_VALUE, MULTIPLIER and TOLERANCE (IE simple calculation:
(t_test.USR_VALUE * t_test.MULTIPLIER >= TOLERENCE)? "OK" : "NO")
You want the expression:
Note that you can add this to the table as a computed column using…
…but be wary of using this value in a WHERE clause where the cost of performing the calculation and lack of index may be prohibitive. Search for indexed calculated columns if you want to take this to the next level.