SQL Server – Altering Column – From Null to Not Null

Two step process to convert NULL to NOT NULL. We will assume that we have a column with a data type of VARCHAR and we are trying to convert it to allow NOT NULL Values.

Step 1: Convert all values to NOT NULL

  1. UPDATE TableName
  2. SET ColumnName = ”
  3. WHERE ColumnName IS NULL

Step 2: Change Column NULL Values

  1. ALTER TABLE TableName
  2. ALTER COLUMN ColumnName VARCHAR(100) NOT NULL

Finally, we are done with Altering Column.

If you enjoyed this blog, please subscribe to be updated on future posts.

Please follow and like us:

Leave a Reply

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