• rabih_karam (1/16/2014)


    WHY U DONT USE THE PIVOT/UNPIVOT STATEMENTS TO TRANSFORM COLUMN DATA INTO MANY COLUMNS??

    Posting in call caps is considered yelling. No need to yell, we are all friends around here.

    The PIVOT statement would work for this also. However, it generally will not perform as well as a cross tab. Additionally, at least for me, they are a lot easier to read and understand.

    Take a look at the articles referenced in my signature about cross tabs. As always, Jeff Moden does an amazing job demonstrating various methods for this type of thing along with performance tests.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/