Is it possible to create a view (not stored procedure) with dynamic column names based on another table? For example:
Code:
CodeId|Description
------------------
1|Title
2|Notes
Data:
DataId|Content|CodeId|GroupId
-----------------------------
1|Title1 | 1| 1
2|Note1 | 2| 1
3|Title2 | 1| 2
4|Note2 | 2| 2
Select Result:
GroupId|Title |Notes
-------------------
1|Title1|Note1
2|Title2|Note2
The column names "Title" and "Notes" would come from the Code
table. I'm guessing the answer is no, but would like to confirm. Thanks!
Edit: I understand how this could be "dangerous". If someone updates the code description the view would change, breaking any SQL dependent on the column names. In that case I could use the CodeId instead, which would not be allowed to change.