Getting the plan handle for a sproc

You can use this T-SQL to get the plan handle for a sproc that has a bad execution plan:

Make sure, to get the proper plan handle text, that you direct the output to text, not a grid.

You can then call the command below to clear the execution plan. Be careful to include the plan handle otherwise you will clear the entire cache!

Do NOT call this:

…as that will clear the entire proc cache and your system will be very slow until it has populated the cache with proc execution plans.

How to Drop One Plan from Cache

Views – 1874

Leave a Reply