How to use a Project in SQL Server Management Studio

By:   |   Updated: 2017-08-28   |   Comments (1)   |   Related: > SQL Server Management Studio


Problem

A problem that SQL Server developers face is where and how to organize code or scripts (T-SQL files) for easy and fast retrieval.  Every DBA/Developer has a set of scripts that are frequently used on a daily basis that need to be loaded and located in a timely manner. SSMS projects can help to organize frequently used files and in this tip we show you how to get started.

Solution

Our solution organizes our most used files in a project. This allows opening the files with a simple mouse click. This tip has two parts; the first is a simple refresh on SSMS projects and the second combines SSMS projects with source control in order to create a shared development environment.

Step 1:

Let’s create our first project. In SSMS and click on File > New > Project...

SSMS - Project Creation

Step 2:

Let’s select “SQL Server Scripts” and name your project.  I chose to name this first project as TestPrj.

Project Creation in a SQL Server Management Studio

Step 3:

To open the Solution Explorer use Ctrl+Shift+O or File > Open > Project/Solution and select your project. If the tasks above are completed successfully, we will see the TestPrj created as follows.

Simple Project Layout in a SQL Server Management Studio Project

Step 4:

Let’s assign our most used servers under the Connections node and add our five most used T-SQL files to the Queries node. The process to add connections or files is fairly easy just right click on “Connections” or “Queries” to add them.

Project Layout in a SQL Server Management Studio Project

One thing that is nice about Projects is the ability to move between scripts just by double clicking on the file listed on the Queries folder. This option comes in handy when several T-SQL scripts are open at the same time.

Step 5:

Where is the Project saved (see image from Step 2) the file looks like the following.

Project Files in a SQL Server Management Studio Project

Step 6:

One thing we need to keep in mind. If we have any open files in SSMS and decide to open our project, the existing files will be closed and the project will be loaded. If we want to keep the existing files open we will have to open our project and select Add > Existing Project from the SSMS File Menu.

Add Existing Project in a SQL Server Management Studio Project

The picture below shows when we add an existing project, all the SSMS open files are placed under the “Miscellaneous Files” folder in "Solution Explorer”.

Miscellaneous Files in a SQL Server Management Studio Project

Conclusion

In this tip, we have seen a simple, but efficient way to organize our files into projects for our most used files or all scripts that are related to a specific application. In the next tip, we will explore how source control can be integrated with our project.

Add source controll to our project in a SQL Server Management Studio Project
Next Steps


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Matteo Lorini Matteo Lorini is a DBA and has been working in IT since 1993. He specializes in SQL Server and also has knowledge of MySQL.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips


Article Last Updated: 2017-08-28

Comments For This Article




Thursday, September 28, 2017 - 4:57:05 PM - Dan Arms Back To Top (66689)

Unfortunately, your tip is a little dated. Microsoft has removed the source control Plug-in Selection piece from from SSMS.















get free sql tips
agree to terms