LessThanDot

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

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.

To 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

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

Related Posts

Another document for the customer's DBA checklist. This time we are going to look how…

About the Author

Jes Borland is a Senior SQL Engineer at Concurrency and a Microsoft Data Platform MVP. She holds an AAS - Programmer/Analyst degree and has worked with SQL Server as a developer, report writer, DBA, and consultant. She is a user group founder, a blogger, and a frequent speaker. In her free time, she runs, cycles, and cooks.

1 Comment so far

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.