T-SQL Guru - Dynamic Pivot on Multiple Columns
Naomi N is our TechNet Guru for May! See more about the Technology Guru TechNet Wiki for May contest.
She had two winning articles. Here is one: T-SQL: Dynamic Pivot on Multiple Columns
And here's an excerpt from the article:
The problem of transposing rows into columns is one of the most common problems discussed in Transact-SQL forum. Many times the problem of creating a dynamic pivot comes into the light. One thing that many people who ask this question forget is that such transposing is much easier to perform on the client side than on the server where we need to resort to dynamic query. However, if we want to make such pivot dynamically, the important thing to understand is that writing dynamic query is only slightly more difficult than writing static query. In fact, when I am presented with the problem of dynamic pivot, I first figure out how static query should look like. Then making such query dynamically becomes rather trivial task.
Read the rest here:
T-SQL: Dynamic Pivot on Multiple Columns
Thanks to Naomi for all your great contributions to the TechNet Guru contest!
- User Ed
Comments
Anonymous
July 26, 2013
This article has been useful in a recent thread social.technet.microsoft.com/.../help-with-a-queryAnonymous
August 02, 2013
Nice! It goes from Forum to Wiki and then back to Forums! This is great!Anonymous
April 30, 2014
another nice post i found: rohit-developer.blogspot.in/.../pivot-with-dynamic-columns-in-sql-server.htmlAnonymous
November 28, 2014
I will present how we can write a Dynamic PIVOT query with an example, where we don’t need to mention the PIVOT columns each unique values. Pivot is one the new relational operator introduced in SQL Server 2005. It provides easy mechanisms in SQL Server to transform rows into columns. for full implementation of Pivot with Dynamic columns check here: <a href="www.mindstick.com/.../Pivot%20with%20Dynamic%20columns%20in%20SQL%20Server" target="_blank">Pivot with Dynamic columns in SQL Server</a>Anonymous
November 28, 2014
I will present how we can write a Dynamic PIVOT query with an example, where we don’t need to mention the PIVOT columns each unique values. Pivot is one the new relational operator introduced in SQL Server 2005. It provides easy mechanisms in SQL Server to transform rows into columns. for full implementation of Pivot with Dynamic columns check here: www.mindstick.com/.../Pivot%20with%20Dynamic%20columns%20in%20SQL%20ServerAnonymous
June 07, 2015
Thanks Kamlakar! You can also post this as an article on TechNet Wiki!Anonymous
January 31, 2016
Computers Today (part 1 of 6) blogs.msdn.com/.../computers-today.aspx ..... CS SPOTLIGHT: Girls in computer programming... why it matters!!! blogs.msdn.com/.../cs-spotlight-girls-in-computer-programming-why-it-matters.aspx ... Computational Thinking - Videos & Papers by Jeannette Wing blogs.msdn.com/.../computational-thinking-videos-amp-papers-by-jeannette-wing.aspx