Why do I get the exception: "ALTER TABLE only allows columns to be added which can contain nulls. Column 'F' cannot be added to table..." with this code?

Joe Sam Shirah

When one adds a column to an existing table with an ALTER TABLE statement, the database adds the column to every row and initializes the column to a value depending on the values supplied in the ADD (COLUMN) clause. If a default value is given, that value is applied; otherwise the column is set to null. SQL Server and some other databases have a current default for assuming NULL/NOT NULL constraints for new columns. If the current default is NOT NULL, but no default value is given in the ADD (COLUMN) clause, this error occurs because the database would otherwise set a null value in a NOT NULL column.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact