• cnayan (3/19/2013)


    My question is the latter one - which is more efficient.

    So do as Lynn suggested IF they both return correct results.

    Looks to me like what you need to do is run some tests to determine 1) You get the results you expect, 2) which one is more effecient if both return the same results.

    I suspect they will both produce the same execution plan. That means that neither one of them is going to be any different. However the first one is FAR easier to read and understand.

    By far the best way to get answers about which of two approaches performs better is to test them on your system!!!

    _______________________________________________________________

    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/