something like thisDECLARE @ColList varchar(max),@SQL varchar(max)SELECT @ColList = STUFF((SELECT ',[' + COLUMN_NAME + ']' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Customers' FOR XML PATH('')),1,1,'')SET @SQL='SELECT *FROM(SELECT RN,DateVal,ValFROM (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS RN,* FROM TableName)tUNPIVOT(Val FOR DateVal IN (' + @ColList + '))u)mPIVOT(MAX(Val) FOR RN IN ([1],[2],[3]))p'EXEC (@SQL)
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs