• No. Not really. This is psuedo-code to describe the situation:

    WITH MyCTE(...)

    INSERT INTO MyTable

    SELECT * FROM MyCTE AS x

    JOIN MyCTE as y

    ON x.ID = Y.ID

    and x.Type=1

    JOIN MyCTE AS z

    ON x.ID = z.ID

    AND z.Type=2

    Something like this will work fine. But if I did this:

    WITH MyCTE(...)

    INSERT INTO MyTable

    SELECT * FROM MyCTE as X

    INSERT INTO MyOtherTable

    SELECT * FROM MyCTE aS y

    That will fail because the CTE only lives as long as the first statement following it's definition, regardless of how many times it's referenced within the statement.

    "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