I have two tables: data and dataMAP. The data table has column names MapID, Real_0, Real_2, Real_3, up to Real_19. Sample data:
1,1.1,2.1,3.1,4.1
1,1.2,2.2,3.2,4.2
1,1.3,2.3,3.3,4.3
DataMAP has has MapID, Real_0_Name, Real_1_Name, to to Real_19_Name. sample data:
1,'forceW','forceX','forceY','forceZ'
2,'distanceW','distanceX','distanceY','distanceZ'
When I query the data table for a given dataMAP ID I'd like the resulting column names to use the values stored in dataMAP for that mapID number.
select * from data where datamap=1 results in:
mapid,Real_0, Real_1, Real_3, Real_4 (these are the column names)
1,1.1,2.1,3.1,4.1
1,1.2,2.2,3.2,4.2
1,1.3,2.3,3.3,4.3
But I want:
MapID,forceW,forceX,forceY,forceZ (these are the column names)
1,1.1,2.1,3.1,4.1
1,1.2,2.2,3.2,4.2
1,1.3,2.3,3.3,4.3
The server is Microsoft SQL 2012.