SQL Server - update only when values ββare different
In SQL Server 2008, how do I update fields in a table only if their values ββdiffer from the values ββin the update statement?
For instance:
I have a TableA with a FirstName column whose value is "Roger Moore" with a unique ID of "007". Now I call the update statement, but it should only update the "FirstName" field if the value is anything other than "Roger Moore".
TIA
+2
a source to share
3 answers
As a rule, it is not worth trying to check the field change
http://blogs.msdn.com/queryoptteam/archive/2006/07/07/659453.aspx
The benefits of blocking are likely to be fulfilled on a conditional update.
However, if you insist on it, you can also look at it "in the background" instead of "trigger" and compare each inserted vs the current values.
+1
a source to share