Four steps for a check constraint on existing data: find the two negative areas, fail to add the rule too early with Msg 547, fix the values and add the rule, then watch an update to minus 5 get rejected

Check Constraint on Existing Data: Clean First, Then Enforce

A check constraint on existing data fails if even one row already breaks the rule. This post finds bad values in a small table of lakes, cleans them, adds the constraint, tightens it with an upper limit, and writes a rule across two columns. It also shows how NULL and WITH NOCHECK behave. Every result comes from SQL Server 2025.

Read More