• fred.newcomer (4/29/2016)


    Thank you for the responses! I was trying to capture the entire query plan during its execution and you say "it's stored just before execution starts"... That's a little confusing. It seems like it ought to be there somewhere! Even so, I can accept that this is an untenable idea and I have devised a less elegant work-around by restructuring the view itself. There is a performance penalty but the downstream error is avoided. My fundamental problem is the way the client application generates its SQL statements and there is nothing I do about that -- so, users will just have to accept whatever limitations may result.

    When I say "just before execution starts" I mean, you must pass the query to the server, it goes through the optimization process to create the plan and upon plan creation, it starts the query. There isn't a place for you in between plan creation and query execution for you to check the plan. There is no pause or gap. Effectively, although not literally, it's of a piece.

    "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