SQL Server execution plans are invaluable for figuring out how a query was run – and how to make it run better. Most of the time that I spend with execution plans is in either SQL Server Management Studio or, more frequently, SQL Sentry’s Plan Explorer. However, many developers spend most of their time in Visual Studio. Is there a way for you to view execution plans using Visual Studio? Yes!

I downloaded and installed Visual Studio Premium 2013 with SQL Server Data Tools. This is the first time I’ve used Visual Studio in…many years. I wasn’t sure what had changed, how much I’d remember about it, and how easy it would be to figure out what I wanted. Turns out, it’s pretty easy to do what I wanted: connect to a database, open a query, and see if I could view an execution plan.

To start, I selected File > New > Project.

On the left I expand Installed > Templates and select SQL Server. I name it and select OK.



The first thing I want to do is connect to my database. I expand out the Server Explorer and click the Add SQL Server option.


A connection box opens; I enter my SQL Server name and credentials. This verifies I have permission to view the server. I can now select View > SQL Server Object Explorer to view the server objects in that pane.

VSSQLServerObjectExplorerTo start a new query, I go to Tools > SQL Server > New Query. I can open an existing query by going to File > Open > File and selecting a .sql file. The query window has a toolbar that has some of the same options as SSMS, although the icons look different.


1. Display Estimated Execution Plan

2. Include Actual Execution Plan

3. SQLCMD mode

The estimated and actual execution plans look and behave the same as they do in SSMS.

An actual execution plan

An actual execution plan

This ability can be helpful if you spend a lot of time working in Visual Studio and want to access execution plans.