Wednesday, March 30, 2011

Set a existing column of MS SQL table as NOT NULL

How to Set a existing column of MS SQL table as NOT NULL?

From stackoverflow
  • ALTER TABLE tablename
    ALTER COLUMN columnname datatype NOT NULL
    

    You will obviously have to make sure that the column does not contain any NULL values before doing this.

  • You might also want to add a default contraint to the column.

0 comments:

Post a Comment