SELECT *
FROM
(
SELECT ParameterName,[VALUES]
FROM @ValueHolder
) AS SourceTable PIVOT(
[VALUES] FOR ParameterName IN(SELECT * FROM @ValueHolder)) AS PivotTable;
Not working.
SELECT *
FROM
(
SELECT ParameterName,[VALUES]
FROM @ValueHolder
) AS SourceTable PIVOT(
[VALUES] FOR ParameterName IN(SELECT * FROM @ValueHolder)) AS PivotTable;
Not working.
The Pivot inner query is incorrect
[VALUES] FOR ParameterName IN(SELECT * FROM @ValueHolder)) AS PivotTable
;
As per MSDN definition
syntax should be
...
PIVOT
(
<aggregation function>(<column being aggregated>)
FOR
[<column that contains the values that will become column headers>]
IN ( [first pivoted column], [second pivoted column],
... [last pivoted column])
) AS <alias for the pivot table>
<optional ORDER BY clause>;
Here IN
clause requires specified column names and will not accept SELECT * expression supported by IN in WHERE clause.
You should consider using dynamic PIVOT syntax. See an example here