Beware using UDFs in check constraints for this reason. This blog post describes your issue. To summarize:
(A UDF) will on the surface do its job, as long as you
INSERT
into the table. But if you update a row and only set the otherColumn for some row from 0 to 1, then the check constraint will not be checked.The optimizer is smart enough to understand that the update doesn't change anything that we refer to in our CHECK constraint, so why bother checking the constraint?
End result here is that the constraint doesn't do what we want it to do. Use a trigger instead (or some other method).
(Emphasis added)