如何修改计算列列名

--------如何修改计算列列名


--必须要先删除 再添加
--
不能直接修改的







---建表
create table test
(
c1 int,
c2 int
cs as (c1+c2)
)
 

---插入数据
insert into test
select 6,2 union all
select 3,4    

--查询表
select * from test


--修改时提示错误

sp_rename 'test.cs','c1*c2'
--注意: 更改对象名的任一部分都可能会破坏脚本和存储过程。
--
消息 4928,级别 16,状态 1,过程 sp_rename,第 520 行
--
无法更改列 'cs',因为它是 'COMPUTED'。

sp_help test

----删除计算列
alter table test 
 drop column cs 


-----增加一列计算列 列名一样即可
 alter table test
 add cs as c1*c2

--查询表
select * from test



---删除表
drop table test
posted @ 2011-10-02 14:54  qingsong_do  阅读(808)  评论(0编辑  收藏  举报