views:

16587

answers:

4

How do you create SQL Server 2005 stored procedure templates in SQL Server 2005 Management Studio?

+3  A: 

You bring up Template Explorer using Ctrl+Alt+T or trough View > Template Explorer. Then you can right click tree nodes to add new Templates or new folders to organize your new templates.

smink
+14  A: 
Chris Woodruff
great use of screen captures. Very good comment!
JD Long
is there a way to make that template a default for sproc template?
roman m
A: 

its nice article but how can i link this template while creating new procedure ?

the default templates are in C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\sqlworkbenchprojectitems\Sql\Stored Procedure be careful changing them and at least back them up if you modify them.
Chris Woodruff
A: 

Little note on your example template

Instead of using IF @@TRANCOUNT > 0 ROLLBACK

We use IF (XACT_STATE()) <> 0 ROLLBACK TRANSACTION; as it seems to provide a better grasp of the state of the transaction

BigEoino
Very cool idea and actually my solution may be getting smelly since it was created a number of years ago. May have to revise it. Thanks for the feedback.
Chris Woodruff