As part of the SQL Pass Manchester / Leeds presentations I did, I showed how you can create your own Script Library to help code re-use within management studio. This is step by step guide to setting up a simple reusable script library in management studio.
First things first you need to in Management Studio
Select View from the menu(1) and Solution Explorer (2)
To create a set of solutions to hold a script library select File (1) New (2) and Project(3)
Ensure that SQL Server Scripts (1) is selected and give a Name for the project (2) and a file location (3)
Ensure that the Create directory for solution is ticked ( if required) (4)
Give the solution a name (5)
Click OK (6)
This creates the solution that can be seen in the solution explorer
Right click the solution and select add / New project
Give the project a name in this case I have called it Daily Scripts (1) leave the location as is (2) and click OK(3)
You can repeat these steps to create a set of folder as shown below.
You can keep adding in projects and it starts to become a useful repository for scripts ( screen shot i have for my projects), which if you open the top level project ( in this case SQLScriptlibrary it will contain all sub projects)
Now if you name the script appropriately you can order then and you have a quick
easy to access code / script repository. Note you can use letters to add in related script in an order.
These are now quite useful to hold scripts that you use or want use again. There are a few advantages of these projects you, as they will remember the last connections you connect to. You can add to source control, pull down and share within teams so you all have access.
These also become useful with bookmarks which is covered in the next blog post