SSMS 2012 - Template Modification

Ran into a situation where i needed to modify the standard templates that SSMS uses to Create Stored Procedures, Functions, and some other scripts.

Problem:
I did not know where to find these templates.

First Solution:
Goto Code Snippet Manager and modify snippets.
Problem with this is that it requires you to create the XML snippet file and even then requires you to put it in, either the Public or Your Profile's, My Snippets folder. This does not solve the immediate problem as i would rather use the Context menu's New Stored Procedure (Function, etc).

After-Thought:
This solution though is great for things such as doing standard Select Statements for your organization.


Second Solution:
Edit the Template used, via Template Explorer.
This created a solution and was exactly what i needed, BUT this is Profile based on not Application based.

This solution is great if you want to do some edits to various templates, but understand that these edits will not be transferred to the SSMS context-menu implementation.  If you do not mind double-click'ing the templates from the Explorer to create the necessary object, then this will be your solution.

Any edits to the templates, via Template Explorer, will be stored in C:\Users\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\Templates\Sql and as such generally not accessible to SSMS as most of us use it.

This does however provide us a way to do mass edits to various SQL templates, thus providing a Part of the solution i need.

Final Solution:
Take Second Solution combined with Cut & Paste to actual directory (Need to be able to execute process as Administrator, when the prompt shows up.

  1. So take the steps completed from the Second Solution, you now need to open and explorer window to the path C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql (Or if you did a custom installation for SSMS, then its respective location, with notable subfolder being SqlWorkbenchProjectItems from the root location of SSMS.exe.
  2. Select either the file or folder, pends on how many edits you made, from the . If you made alot of SQL file edits acrossed multiple folders, then select either the folder(s) you made the edits in, or the parent folder of them.
  3. Now the most import, AND SUPER CRITICAL STEP, Copy & Paste the folder(s), from Step 2, and paste them into C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql. This of course pending on how many edits, but i would localize the paste into the folder(s) that you made the edits.

Result:
Now you can take these SQL Template files and use them from the Context menu in the various options available.  Most notable, for my situation, where the *.sql files with (New Menu) in the filename.

Comments

Popular posts from this blog

SysInternals - BgInfo for ALL Users

JSON/AJAX Helpers

Acquiring List of controls - Classic JS