如何将普通列更改为“计算”?柱 [英] How to change a normal column to "computed" column

查看:58
本文介绍了如何将普通列更改为“计算”?柱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MSSQL Server 2008中有一个表。我想将该表中的列之一更改为计算列。有人可以告诉我该怎么办吗?

I have a table in MSSQL server 2008. I would like to change one of the column in that table to computed column. Could somebody tell me how do I do that ?

推荐答案

保留旧数据:

EXEC sp_rename 'MyTable.OldCol', 'RenamedOldCol', 'COLUMN';

添加计算列

ALTER TABLE MyTable ADD ComputedCol AS (some expression);

然后,

Then, when you're happy

ALTER TABLE MyTable DROP COLUMN RenamedOldCol;

这篇关于如何将普通列更改为“计算”?柱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆