Home Forums SQL Server 2005 Administering Very strange behaviour - Multiple Exec plans - Attached is the complete code RE: Very strange behaviour - Multiple Exec plans - Attached is the complete code

  • Lynn Pettis (4/10/2013)


    I think I know why, the table #test are different tables when the stored procedure is run in different sessions. Therefore you will get separate plans for the execution of the stored procedure. If you run the second batch a second time in the same session it reuses the plan originally created.

    Edit: Actually the temporary table #test is different when created from different sessions.

    A new plan for each new session, even. There's some useful info here.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden