How do I obtain a Query Execution Plan in SQL Server

0 votes
How can I get a query execution plan for a query / stored procedure In Microsoft SQL Server?
Sep 19 in Database by Kithuzzz
• 20,660 points
87 views

1 answer to this question.

0 votes

There are several ways to get an execution plan; which strategy you pick will depend on your situation. Normally, you can get a plan using SQL Server Management Studio, but if for some reason you can't run your query in that tool, you might find it useful to be able to retrieve a plan using SQL Server Profiler or by looking through the plan cache.

Using SQL Server Management Studio.
The "Include Actual Execution Plan" menu item, which can be located under the "Query" menu, must be checked before running your query as usual in order to capture an execution plan in SQL Server.

Include Action Execution Plan menu item

You should run the stored procedure as follows if you're attempting to acquire the execution plan for statements in the method:

exec p_Example 42

When your query has finished running, a new tab labeled "Execution plan" ought to show up in the results window. If you run a lot of statements, this tab can show a lot of plans.
From here, you may open SQL Server Management Studio and view the execution plan, or you can right-click the plan and choose "Save Execution Plan As..." to save it to a file in XML format.

See also:

answered Sep 20 by narikkadan
• 37,660 points

Related Questions In Database

0 votes
0 answers

How do I query for all dates greater than a certain date in SQL Server?

I tried this: SELECT * FROM dbo.March2010 A WHERE ...READ MORE

Aug 29 in Database by Kithuzzz
• 20,660 points
76 views
0 votes
0 answers

How can I show the table structure in SQL Server query?

Query: SELECT DateTime, Skill, Name, TimeZone, ID, User, ...READ MORE

Aug 11 in Database by Kithuzzz
• 20,660 points
112 views
0 votes
0 answers

How do I view the Explain Plan in Oracle Sql developer?

I want to check the query execution ...READ MORE

Aug 19 in Database by Kithuzzz
• 20,660 points
229 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 7,020 points
168 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4 in Database by Vaani
• 7,020 points
71 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4 in Database by Neha
• 8,940 points
302 views
0 votes
1 answer

LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

At the top level there are mainly ...READ MORE

answered Feb 4 in Database by Neha
• 8,940 points
290 views
0 votes
1 answer

How do I run an sql query in php?

Try this: <?php $conn = new mysqli('localhost', 'jaydeep_mor', 'jaydeep_mor', ...READ MORE

answered Sep 10 in Database by narikkadan
• 37,660 points
56 views
0 votes
1 answer

How do I perform the SQL Join equivalent in MongoDB?

The majority of the responses to this ...READ MORE

answered Sep 15 in Database by narikkadan
• 37,660 points
133 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP