Overview
Here's another product suggestion I've logged with Microsoft along the same lines as the previous one. This one is to allow you to dynamically specify the list of columns you want to unpivot. This might be from a stored procedure parameter or a subquery, either way you can't do it easily at the moment. Register your support here:
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=332512
Detail
Current behaviour
UNPIVOT (value FOR column_name IN (Col1, Col2, Col3, Col4))
All columns must be known in advance and specified in full.
Suggested behaviour with subquery using a table-valued parameter
UNPIVOT (value FOR column_name IN (SELECT colname FROM @tblParam))
Columns can be determined at runtime.
Versions
- SQL Server 2008
- SQL Server 2005
Metadata
- Categories: IT Management, Software Development, SQL Server
- Additional keywords: UNPIVOT, dynamic column lists
- Technorati Tags:
SQL,
SQL Server,
UNPIVOT