如变换类型的修改,将xh int改为xh char(10),用脚本修改: alter table a2 add xh1 char(10) go update a2 set xh1 = cast(xh as char(10)) go alter table a2 drop column xh go sp_rename 'a2.xh1', 'xh', 'column' go
对!对一些不能隐式转换的要alter table a2 add xh1 char(10) go update a2 set xh1 = cast(xh as char(10)) go alter table a2 drop column xh go sp_rename 'a2.xh1', 'xh', 'column' go 这样写!
所以现在搞得我不太敢动 有数据的数据库了 是不是只要影响数据 它都会提示
alter table a2
add xh1 char(10)
go
update a2 set xh1 = cast(xh as char(10))
go
alter table a2
drop column xh
go
sp_rename 'a2.xh1', 'xh', 'column'
go
这样损失就大了
ALTER TABLE 你的表 ALTER COLUMN 列名 你的类型 NOT NULL
或者:
T-sql脚本修改:
ALTER TABLE 你的表 ALTER COLUMN 列名 你的类型 NOT NULL
sqlserver 是没有问题的。
add xh1 char(10)
go
update a2 set xh1 = cast(xh as char(10))
go
alter table a2
drop column xh
go
sp_rename 'a2.xh1', 'xh', 'column'
go
这样写!