Displaying the SQL plan for cached statements

View the plan for a cached statement using these functions:

show_plan(spid, batch_id, context_id, statement_number)

Where:

For a statement that is not performing well, you can change the plans by altering the optimizer settings or specifying an abstract plan.

When you specify the first int variable in the existing show_plan argument as “-1”, show_plan treats the second parameter as a SSQLID.

NoteA single entry in the statement cache may be associated with multiple, and possibly different, SQL plans. show_plan displays only one of them.