SQL Solutions – Reusable script Library

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)

Solutions

To create a set of solutions to hold a script library select File (1) New (2) and Project(3)

Projects

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)

Script_Library

This creates the solution that can be seen in the solution explorer

Solution_explorer

Right click the solution and select add / New project

New_Solutions

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)

DailyScripts

You can repeat these steps to create a set of folder as shown below.

Monthly_scripts

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)

SQLScriptLibrary

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.

Security

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

 

 

 

 

 

 

 

 

Advertisements
This entry was posted in Configuration, Management Studio, Productivity, Tips & Tricks. Bookmark the permalink.

One Response to SQL Solutions – Reusable script Library

  1. Pingback: SQL Solutions – Part 2 bookmarks | SQL Server Solutions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s