use tempdb goif object_id('#temp') is not null drop table #temp create table #temp(id int not null ,name char(20) not null) --查看表结构 exec sp_help #temp--去掉not null alter table #temp alter column name char(20) null--再查看表结构 exec sp_help #temp
ALTER TABLE ALTER COLUMNname type NULL
ALTER tabname ALTER COLUMN colname type NULL
ALTER table tabname ALTER COLUMN columname type NULL
要是在列上建立了其他对象,如索引,就不能更改NOT NULL了 这种情况如何处理
Create table a (a int not null)ALTER table a ALTER COLUMN a int NULL exec sp_help a--查看系统结构
alter table ta ALTER column colname type null
goif object_id('#temp') is not null
drop table #temp
create table #temp(id int not null
,name char(20) not null)
--查看表结构
exec sp_help #temp--去掉not null
alter table #temp
alter column name char(20) null--再查看表结构
exec sp_help #temp
ALTER TABLE ALTER COLUMNname type NULL
这种情况如何处理