What's the problem with NOT NULL columns?

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

What's the problem with NOT NULL columns?

Postby DerekR » Fri May 04, 2012 10:41 am

Can someone explain what the big deal is with being unable to propogating new columns that are marked as NOT NULL?
Obviously, in the source DB these columns have data so isn't it just a case of dropping this constraint, altering the table (or drop/create), importing the data and reapplying the NOT NULL property?
I don't want to get into writing migration scripts and I think forcing me into taking the NOT NULL property off the source table, then reapplying can't be right either, I put it there for a reason.


Posts: 3
Joined: Fri Apr 27, 2012 2:42 pm

Postby David Atkinson » Fri May 04, 2012 2:32 pm

The problem is that it's not possible to add the NOT NULL constraint to a table that has pre-existing data without doing an UPDATE to set the existing rows. SQL Compare can't second guess what these values should be.

David Atkinson
Red Gate
David Atkinson
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 1 guest