How to use a Project in SQL Server Management Studio
By: Matteo Lorini | Updated: 2017-08-28 | Comments (1) | Related: More > SQL Server Management Studio
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.
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.
Let’s create our first project. In SSMS and click on File > New > Project...
Let’s select “SQL Server Scripts” and name your project. I chose to name this first project as TestPrj.
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.
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.
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.
Where is the Project saved (see image from Step 2) the file looks like the following.
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.
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”.
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.
- Display Line Numbers in SSMS
- SQL Server Management Server Tips.
- Team Foundation Server as Version Control.
Last Updated: 2017-08-28
About the author
View all my tips