Find Scripts Quickly in SQL Server Management Studio

Sometimes it’s the little things that drive you nuts. For me, one of those things is trying to find and open SQL scripts from inside SQL Server Management Studio (SQLMS). Sure, it remembers the folder where you last opened files, but if you want to open files in a different folder, you have to navigate through your hard drive for them.

Your alternative is to put your SQL scripts under the SQLMS "My Projects" folder, but that approach doesn’t fit my work style. I organize stuff on my hard disk by project, so all the scripts associated with a given project are in a subfolder under the project’s root folder.

If you have a top-level Projects folder that you put all of your projects under, you could tell SQLMS to use that folder as the My Projects folder. That would save you a little navigation effort. Alas, nowhere in the SQLMS option settings could I find a place to set the location of the My Projects folder. I think I remember doing that in the "old days" of "Enterprise Mangler."

However, I did find the registry key that controls the My Projects folder location:

  HKEY_CURRENT_USERSoftwareMicrosoftMicrosoft SQL Server90ToolsShell

I don’t like tweaking the registry unnecessarily, and after thinking about it some more, I realized that I’d still be doing a lot of folder navigation. That’s when inspiration struck. I realized that what I really needed was shortcuts to the project script folders. SQLMS always shows the My Projects link on the task bar when you open a file, so that seemed like the logical place to hook in.

So now, whenever I create a new folder for SQL scripts, I use the following procedure to make it easy to find from within SQLMS:

  • In Windows Explorer, navigate to the script folder you want to use.
  • Right-click the folder and choose Create Shortcut. Explorer creates a "Shortcut to [folder_name]" shortcut for you under the same parent folder as the original folder.
  • Cut the shortcut and paste it into your SQLMS My Projects folder. That folder is normally located under "My DocumentsSQL Server Management StudioProjects."
  • I usually also rename the shortcut to something like "[project_name] Scripts," but that’s up to you.

Now, whenever you open or save a file from within SQLMS, you can quickly get to all of your script folders (see below). If the default folder displayed in the file dialog is not where you want to be, just click "My Projects" in the task pane and select the appropriate shortcut. It sure beats navigating your hard drive repeatedly!

Open File dialog showing script folder shortcuts

Open File dialog with script folder shortcuts