我有一个名为 Employee 的表
Eno ename AttributeValue AttributeName
1 aa a123 abc
2 bbb b123 dcf
3 cc c7sd wew3
我想将列 AttributeValue
中的数据交换到 AttributeName
并将 AttributeName
交换到 AttributeValue
例如:
Eno ename AttributeValue AttributeName
1 aa abc a123
2 bbb dcf b123
3 cc wew3 c7sd
最佳答案
UPDATE employee
SET AttributeValue = AttributeName,
AttributeName = AttributeValue
但是,除非两列具有完全相同的定义,否则您将面临丢失信息的风险。
关于sql - 如何在 sql server 2008 中交换列值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4198587/