How can i make not allow column to allow null and Allow Null column to not allow null
Could any one help me to perform below task.
How can i make not allow column to allow null and Allow Null column t开发者_Go百科o not allow null.
Use ALTER TABLE table_name ALTER COLUMN column_name datatype [NOT] NULL
Example:
CREATE TABLE #Foo
(
X INT NULL,
Y INT NOT NULL
)
/*This is metadata only change and very quick*/
ALTER TABLE #Foo ALTER COLUMN Y INT NULL
/*This requires all rows to be scanned to validate the data*/
ALTER TABLE #Foo ALTER COLUMN X INT NOT NULL
精彩评论