22,210
社区成员
发帖
与我相关
我的任务
分享
create table gs(a int,b int,c as a+b)
insert into gs(a,b)
select 1,2 union all
select 3,5
select * from gs
/*
a b c
----------- ----------- -----------
1 2 3
3 5 8
(2 row(s) affected)
*/
alter table gs add c2 int
update gs set c2=c
alter table gs drop column c
sp_rename 'gs.c2','c','column'
--结果
select * from gs
/*
a b c
----------- ----------- -----------
1 2 3
3 5 8
(2 row(s) affected)
*/
create table gs(a int,b int,c as a+b)
insert into gs(a,b)
select 1,2 union all
select 3,5
select * from gs
/*
a b c
----------- ----------- -----------
1 2 3
3 5 8
(2 row(s) affected)
*/
--备份数据
select * into #gs from gs
--删除公式
drop table gs
create table gs(a int,b int,c int)
--导入数据
insert into gs(a,b,c)
select * from #gs
--结果
select * from gs
/*
a b c
----------- ----------- -----------
1 2 3
3 5 8
(2 row(s) affected)
*/