I have a db table that previously was not null (so every record had a value). I now want to make it nullable so its optional but it seems like SQL won't let you do this without deleting and recreating the table.
Why would it have this restriction if no data will be affected as I am going to a more lenient model (not a stric开发者_开发技巧ter one)?
You can stop the table designer from blocking you: Tools | Options | Designers | Table and Database Designers > uncheck "Prevent saving changes that require table re-creation".
ALTER TABLE table_name ALTER COLUMN column_name data_type NULL
You can:
create table test (id int not null)
insert test values (1), (2), (3), (4), (5)
insert test values (null) -- fails
alter table test alter column id int null
insert test values (null) -- succeeds
select * from test
精彩评论