SQL Server: Dynamic column lists with UNPIVOT — Give your support

by Stephen Horsfield 11. March 2008 12:36

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: , ,

Tags:

IT Management | Software Development | SQL Server

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar