• Sorry, I misunderstood. When you said line, I thought you meant a row of data, rather than a Line ID in your data. You need to use dynamic SQL plus either PIVOT or a "Crosstab" solution using case statements. Have a look at Jeff Moden's article on the subject:

    http://www.sqlservercentral.com/articles/Crosstab/65048/