• Luis and Sean beat me to it... I was going to add, here's a good article on this subject:

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns[/url]

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001