SQL: Make column NOT NULL but don't check existing data in SQL Server

A forum poster was asking how to make a SQL Server column NOT NULL, but not apply it to old data. But when you add NOT NULL, there's no option to say "Just new data". However, you can work around it to achieve the same goal.

When you add a constraint to SQL Server, you can say WITH NOCHECK. That says to not check existing data. You can add a constraint to ensure a value isn't NULL.

Here's an example:

I hope that helps someone.

2 thoughts on “SQL: Make column NOT NULL but don't check existing data in SQL Server”

Leave a Reply

Your email address will not be published. Required fields are marked *