如何在 sql server 2008 中交换列值? [英] How do I swap column values in sql server 2008?
本文介绍了如何在 sql server 2008 中交换列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张名为 Employee 的表
I have a table called Employee
Eno ename AttributeValue AttributeName
1 aa a123 abc
2 bbb b123 dcf
3 cc c7sd wew3
我想将 AttributeValue
列中的数据交换为 AttributeName
并将 AttributeName
列交换为 AttributeValue
I want to swap the data from column AttributeValue
to AttributeName
and AttributeName
to AttributeValue
例如:
Eno ename AttributeValue AttributeName
1 aa abc a123
2 bbb dcf b123
3 cc wew3 c7sd
推荐答案
UPDATE employee
SET AttributeValue = AttributeName,
AttributeName = AttributeValue
但是,除非两列具有完全相同的定义,否则您可能会丢失信息.
However, unless both columns have the exact same definition, you risk losing information.
这篇关于如何在 sql server 2008 中交换列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文