jueves, 29 de noviembre de 2012

SSMS Shared SQL Templates, synchronized with Dropbox account

Actually, I've T-SQL scripts in my USB, but today I'm thinking about the possibility to store it in Template Explorer of Management Studio, it's more fast to get scripts than in USB.

First of all, Scripts of Template Explorer are stored in %AppData%\Microsoft\Microsoft SQL Server\100\Tools\Shell\Templates\SQL

100 for SQL Server 2008 R2, the number depends on your SQL Server version.

It's not possible to modify the path of Template Explorer, but it's possible to modify the content of the path.

For me, it's a good option to link the content with Dropbox Folder, to synchronize it.

Windows 7 has introduced a new shell command called MKLINK, which can create symbolic links.

Well, first of all we have to rename SQL folder:

  • Open command prompt and type
    • cd %AppData%\Microsoft\Microsoft SQL Server\100\Tools\Shell\Templates
      For SQL2012: cd %AppData%\Microsoft\SQL Server Management Studio\11.0\Templates\SQL
    • ren SQL SQL_OLD

Now link Dropbox Folder to SQL Directory.

  • mklink /D Sql C:\Users\USER\Dropbox\SCRIPTS (Change it for your desired path).

Now, open SQL Server Management Studio a go to View Menu, Template Explorer (Ctrl+Alt+T).

If all goes ok, you have to view you Dropbox Folder with all .sql file extension.

Something like this.

SQL Server always creates his template scripts in folder, if you try to delete it, on next program execution it will re-created.
In example, non numbered directories, are default SQL Server Template Folders.

Note: If you doesn't find Template folder in  %AppData%\Microsoft\Microsoft SQL Server\100\Tools\Shell\, go to SSMS and open Template explorer, now folder will be created.
It's only necessary do this for first time after installation.

The path for SQL2012 is %AppData%\Microsoft\SQL Server Management Studio\11.0\Templates\SQL

No hay comentarios:

Publicar un comentario