How to remove not null constraint in sql server using query

Sql ServerSql

Sql Server Problem Overview


I am trying to remove not null constraint in sql server 2008 without losing data.

Sql Server Solutions


Solution 1 - Sql Server

 ALTER TABLE YourTable ALTER COLUMN YourColumn columnType NULL

Solution 2 - Sql Server

Remove constraint not null to null

ALTER TABLE 'test' CHANGE COLUMN 'testColumn' 'testColumn' datatype NULL;

Solution 3 - Sql Server

Remove column constraint: not null to null

ALTER TABLE test ALTER COLUMN column_01 DROP NOT NULL;

Solution 4 - Sql Server

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShantanu GuptaView Question on Stackoverflow
Solution 1 - Sql ServerMichael PakhantsovView Answer on Stackoverflow
Solution 2 - Sql ServerNan YuView Answer on Stackoverflow
Solution 3 - Sql ServerPasQualEView Answer on Stackoverflow
Solution 4 - Sql ServerRujoota ShahView Answer on Stackoverflow