Common Table Expressions - who's responsible?

  • Are CTE's usually created by the DBA or the Developer? I am new to CTE's, and since they don't appear to be stored or built into the database, it almost looks like the CTE should be created by the Developer for the needs of the application. Is this typical in a shop?

  • A CTE is just a part of the query that needs it. As a matter of fact, a CTE must be consumed by the very next statement and can't be used in multiple statements within a query (and yes, before anyone corrects me, I know about nesting CTE's & recursion). So, who writes your stored procedures and queries now? Those same people will have CTE's available to use as appropriate.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • reefshark (5/4/2010)


    Are CTE's usually created by the DBA or the Developer?

    it has nothing to do with developer or DBA , the person whoi knows/wants to work on TSQL , can work on it.

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • A CTE, despite its name, is not a table. It's a named select statement. Think of it as a temporary view, defined and used within the same SQL query.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply