I have 2 tables
Table 1:
DB1, DB2, DB3, DB4, DB5, Some other identifiers
Table 2:
EnumText, EnumValue, Some other identifiers
What I want to do is to:-
- Select data from Table 1
- During Select, change the alias of columns DB1 to DB5 using the Data in Table 2’s EnumText column where EnumValue will contain DB1 to DB5.
A sample command would be:
Select
DB1 as [Select EnumText from Table2 where EnumValue='DB1'],
DB2, DB3
from Table1
This command won’t work but I hope you people got the idea.
Thank you in advance.
You can’t have dynamic aliases without dynamic SQL. If you did change the resultset column names, how do you access them via name? (I wouldn’t use index because it will break)
So, you can add a fixed column to describe it. And read that