Home Forums SQL Server 2008 T-SQL (SS2K8) Returning stored procedure results into a CTE or temp table? RE: Returning stored procedure results into a CTE or temp table?

  • Sean Lange (8/20/2013)


    GilaMonster (8/20/2013)


    A CTE however, despite its name, is not a table and hence can not have anything inserted into it.

    Acutally you can insert into a cte, just like you can delete from them.

    No, actually you can't. What you can do is insert into a table (permanent, temporary or variable) through a CTE, just as you can with a view (if it is updateable).

    You're not inserting into the CTE because a CTE has no persistent storage, it's just a select statement. The insert is into the base tables that the CTE is defined upon.

    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