Click here to Skip to main content
15,903,523 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

SQL
-- 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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900