There were some quetions in the forums about transposing data without the use of aggregate functions. While building a CSV list is nice sometime that's not what we want. So this is a sproc that does just that. It's nothing complex, it just gets the max number data in groups and builds an SQL statement with that many left joins.
create proc spTranspose
@TableName varchar(100),
@PrimaryCol varchar(100), -- parent column to transposing columns
@SecondaryCol varchar(1000) -- CSV string of columns to transpose
as
select @SecondaryCol = replace(@SecondaryCol,...