Create dynamic PIVOT queries in SQL Server.

In this Script we will look how we can dynamically create the pivot Script to handle the unknown values. USE AdventureWorks2012; GO CREATE TABLE dbo.Players ( FormatID INT, PlayerID INT , Name NVARCHAR(255) NOT NULL, Formats Varchar(50), Average Int ); INSERT dbo.Players VALUES (1,1, N’MS Dhoni’,’ODI’,55), (1,2, N’Rohit Sharma’,’ODI’,40), (1,3, N’Virat kholi’,’ODI’,60), (1,4, N’ABD’,’ODI’,60), (2,1, … More Create dynamic PIVOT queries in SQL Server.