Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customise default 'New Stored Procedure' SSMS 2008 Template

I am trying to customise the default query which is put in place when you click New Stored Procedure... from the Object Explorer on SQL Server Management Studio 2008.

I have found how to change the 'Create Stored Procedure (New Menu)' template from the Template Explorer, however this means I will have to keep opening the template explorer rather than clicking on new stored procedure like i usually would.

How can I edit the template which appears when you click New Stored Procedure... ?

like image 559
Curtis Avatar asked Jul 05 '10 15:07

Curtis


People also ask

How modify and save a stored procedure in SQL Server 2008?

Use SQL Server Management StudioExpand Stored Procedures, right-click the procedure to modify, and then select Modify. Modify the text of the stored procedure. To test the syntax, on the Query menu, select Parse. To save the modifications to the procedure definition, on the Query menu, select Execute.

How do I edit a SQL template?

Open Template Browser. Right-click SQL Server Templates, and then select New > Folder. Right-click the template you created, and then select Edit.

Where are templates stored in SSMS?

Templates are boilerplate files containing SQL scripts that help you create objects in a database. The first time the template explorer is opened, a copy of the templates are placed in the user's folder in C:\Users, under AppData\Roaming\Microsoft\SQL Server Management Studio\130\Templates.

Why set Nocount on is used in SQL?

SET NOCOUNT ON prevents the sending of DONEINPROC messages to the client for each statement in a stored procedure.


2 Answers

For SQL Server 2008, find this directory :

C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql\Stored Procedure\

or for those on x64 Windows,

C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql\Stored Procedure\

Within are 6 .sql files:

  • Alter
  • Create Basic
  • Create with Cursor
  • Create with Output
  • Create from New Menu
  • Drop

Edit as you like!

For SQL Server 2012,

C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql\Stored Procedure

like image 174
p.campbell Avatar answered Oct 20 '22 05:10

p.campbell


Works for SSMS 2005 and 2008:

In the menu click View/Template Explorer (or Ctrl-Alt-T)

Within the Template Explorer which opens, find:

Stored Procedure/Create Stored Procedure (New Menu)

Edit: Additional explanation

Right click and choose Edit in the popup menu to alter the file directly.

like image 33
nurettin Avatar answered Oct 20 '22 05:10

nurettin