将数据从一个表复制到另一个表 [英] Copy data from one table to another table
本文介绍了将数据从一个表复制到另一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张表格,数据如下:
Id日期设定名称设定价值
1 01/10/2013 Car 10
2 01/10/2013自行车20
3 01/10/2013周期30
i想要将这些数据插入另一张桌子
日期汽车自行车周期
01/10/2013 10 20 30 < br $> b $ b
plaese提供sql查询来移动数据。
I have one table with data as given below
Id Date SettingName SettingValue
1 01/10/2013 Car 10
2 01/10/2013 Bike 20
3 01/10/2013 Cycle 30
i want to to insert this data in another table
Date Car Bike Cycle
01/10/2013 10 20 30
plaese provide sql query to move the data.
推荐答案
访问这里....
http://blog.sqlauthority.com/2012/10/31/ sql-server-copy-data-from-one-table-to-another-table-sql-in-sixty-seconds-031-video / [ ^ ]
或
http://www.sqlservercentral.com/Forums/Topic503363-8-1.aspx [ ^ ]
visit here....
http://blog.sqlauthority.com/2012/10/31/sql-server-copy-data-from-one-table-to-another-table-sql-in-sixty-seconds-031-video/[^]
or
http://www.sqlservercentral.com/Forums/Topic503363-8-1.aspx[^]
-- TempTable
Select DATE,Car,Bike,Cycle Into #TableName
From
(Select DATE,SettingName,SettingValue From T01)u
PIVOT(Sum(SettingValue) For SettingName in(Car,Bike,Cycle)) AS Pvt
-- New Table
Create Table TableName (Columns)
Insert TableName
Select DATE,Car,Bike,Cycle
From
(Select DATE,SettingName,SettingValue From T01)u
PIVOT(Sum(SettingValue) For SettingName in(Car,Bike,Cycle)) AS Pvt
这篇关于将数据从一个表复制到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文