Home Forums SQL Server 2012 SQL Server 2012 - T-SQL What is wrong with this syntax? Query will work, but CTE will not "compile" RE: What is wrong with this syntax? Query will work, but CTE will not "compile"

  • Eirikur Eiriksson (4/8/2014)


    hisakimatama (4/8/2014)


    Aha, so it doesn't :-). I've always declared CTEs with the column declarations, and by the wonderful problems of habit, it stuck as "the" way to do it. Well, I learned something that should make syntax a good bit clearer myself 😀

    I prefer it, makes the code more readable.

    😎

    I've found just the opposite to be true if there are a ton of columns being returned by the CTE. I'd just as soon write it as a good and proper encapsulated SELECT and let the defintion of the CTE be simple.

    But, to each their own! I even change my ways when I'm working for a different company and they say how they want it done. 😛

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)