-- test table Create table zz_PivotTest ( ID int identity(1,1), [Year] int not null, [type] int not null, amt int not null ) insert into zz_PivotTest ([Year], [type], amt) values (1999, 1, 23) insert into zz_PivotTest ([Year], [type], amt) values (1999, 2, 44) insert into zz_PivotTest ([Year], [type], amt) values (1999, 3, 55) insert into zz_PivotTest ([Year], [type], amt) values (2000, 1, 66) insert into zz_PivotTest ([Year], [type], amt) values (2000, 2, 77) insert into zz_PivotTest ([Year], [type], amt) values (2000, 3, 88) -- run proc exec sp_Query_Pivot 'select * from zz_PivotTest', '[year]', '[type]', 'Select distinct [type] from zz_PivotTest', 'SUM', '[amt]', 'Y'