I am creating a temp table and want to loop through the rows in that temp table and then use the values as column names in a select statement in another query.
Temp Table
Reviewer | Status
---------------------------
Reviewer1 | Under Review
Reviewer2 | Approved
Reviewer3 | Denied
Reviewer4 | Under Review
Desired Result
Reviewer1 | Reviewer2 | Reviewer3 | Reviewer4
------------------------------------------------------------
Under Review | Approved | Denied | Under Review
I've followed this example: Setting column values as column names in the SQL query result and can get it to work with a pre-defined numbers of rows/values in the temp table, but I will have an undefined number of Reviewers and I can't get the dynamic select version to work because SQL does not have a Group_Contact function.
I've been stuck on this awhile and would appreciate any advice.