SQL Server: Copying column within table

自古美人都是妖i 提交于 2019-12-09 14:05:46

问题


What is the easiest way to copy the all the values from a column in a table to another column in the same table?


回答1:


With a single statement (if the columns have the same datatype)

UPDATE <tablename>
SET <destination column name> = <source column name>



回答2:


This script will update ALL values in the field1 with the values from the field2 in the corresponding row

UPDATE table SET field1 = field2


来源:https://stackoverflow.com/questions/173717/sql-server-copying-column-within-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!