Hi Visakh,
Below is My Query
/*Declare Variable*/DECLARE @Column [nvarchar](max);
DECLARE @Query [nvarchar](max);
/*Select Pivot Column*/
SELECT @Column= COALESCE(@Column+',','')+ QUOTENAME([Date]) FROM
(SELECT DISTINCT [Date] FROM [TEST].[dbo].[Product])Tab
SELECT @Query='SELECT [ProductID],[ItemID], '+@Column+'FROM
(SELECT [ProductID],[ItemID], [Date] , [Qty] FROM [TEST].[dbo].[Product] )Tab1
PIVOT
(
SUM(Qty) FOR [Date] IN ('+@Column+')) AS Tab2
ORDER BY Tab2.ProductID,[ItemID]'
I need to store @Query results in table.Like below is the example
select * into temppfrom [TEST].[dbo].[Product]
Regards,
Niranjan B