[sql-server] Can I change a column from NOT NULL to NULL without dropping it?

Need to alter a table to allow nulls on a column -- but cant drop the column...can I do this? Was trying something like:

ALTER TABLE myTable MODIFY myColumn NULL;

But to no avail....

This question is related to sql-server

The answer is


ALTER TABLE myTable ALTER COLUMN myColumn {DataType} NULL

where {DataType} is the current data type of that column (For example int or varchar(10))


Sure you can.

ALTER TABLE myTable ALTER COLUMN myColumn int NULL

Just substitute int for whatever datatype your column is.


For MYSQL

ALTER TABLE myTable MODIFY myColumn {DataType} NULL