Tuesday, October 6, 2020

How to write dynamic pivot query in SQL Server

How to write dynamic pivot query in SQL Server





This video show how to write dynamic pivot query in sql server. Dynamic pivot query is useful when you want to display data in columns instead of rows where you are not confirm you much row will be converted to columns.


Pivot query in sql is used to convert rows to columns where generally you need to explicitly declare which row value will be converted to which column which is possible when you know all the values of the row
values to pivot. When you have a variable number of pivot values then dynamic pivot query might be very helpful.