DECLARE @test TABLE (Id uniqueidentifier default newID(), ColumnId int, RowId INT) INSERT @test ( ColumnId, RowId ) VALUES ( 1,1 ) INSERT @test ( ColumnId, RowId ) VALUES ( 1,2 ) INSERT @test ( ColumnId, RowId ) VALUES ( 2,1 ) INSERT @test ( ColumnId, RowId ) VALUES ( 2,2 ) SELECT * FROM @test SELECT RowID, cast([1] as uniqueidentifier) as Column1, cast([2] as uniqueidentifier) as Column2 from (select cast(Id AS BINARY(16)) AS id, columnId, rowID FROM @test) tmp pivot ( max( id ) for columnID in ([1],[2]) ) AS pvtBut think twice, should you do this. Probably there is a better way using apply or Linq.
PivotTestTable.AsParallel() .GroupBy (pt => pt.RowId ) .Select (pt => new { RowId = pt.Key, Column1 = pt.SingleOrDefault (p => p.ColumnId==1).Id, Column2 = pt.SingleOrDefault (p => p.ColumnId==2).Id })Cetin