how to define a query plan when executing sp

  • Hey you guys, i have a sp which processes certain amount of data, but something strange happens that the execution duration ranges widely according to the way to run it: when run it by the sp name like "exec [someSP]" or invoke it from outside, it turns out to be very slow like an hour or longer while only minutes cost if execute the sql code composing the sp in the query windows, I believe different query plans are created when run them differently, now I have to run the sp from the outside(which costs a lot of time), is anything i can do to the query plan to make it as fast as when I run the sql code?

    thanks in advanced

  • Use Profiler to capture the execution plans for the two ways of running the code, and then compare them.

    John

  • This is a duplicate of this question. Please don't do that. I just confuses the conversation and makes it harder for people to read and understand what's going on. Please post all follow-ups on the other thread.

    "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

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

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