Monday 5 April 2021

MSSQL - Fix Error - ALTER TABLE only allows columns to be added that can contain nulls, or have a DEFAULT definition specified, or the column being added is an identity or timestamp column, or alternatively if none of the previous conditions are satisfied the table must be empty to allow addition of this column. Column 'IsValid' cannot be added to non-empty table 'Test1' because it does not satisfy these conditions.

 Watch this example on YouTube


 

To fix it replace

 Alter Table Test1
Add IsValid bit not null

 with  

Alter Table Test1
Add IsValid bit not null Default 0

No comments:

Post a Comment