Is it possible to create a view (non-stored procedure) with dynamic column names based on another table? For instance:
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” will come from the Code table. I suppose the answer is no, but I would like to confirm. Thanks!
Edit: I understand how this can be "dangerous." If someone updates the code description, the view will change by breaking any SQL that depends on the column names. In this case, I could use CodeId instead, which would not be allowed to change.
source share