SQLServerCentral Editorial

Guest Editorial: In Praise of Templates

,

I'm a 'plain-screen' man, by preference. On occasion, when I'm doing database development work I can, and do, dispense with Management Studio (SSMS) altogether. "Point 'n click" is OK for ad-hoc work, but it soon becomes drudgery. However, there are a few wonderful features of SSMS that keep me hanging on in with it, chief among them being templates.

They seem to be SSMS's best-kept secret but, when you've got to do some complicated admin jobs to do, the templates are a godsend. Just open up the template explorer (Control-Alt-T), and find the template you want. Double-clicking on the template will open it up in a new query window, or you can simply "drag 'n drop" the template into an existing query window. Hit Control-Shift-M and up pops a screen, inviting you to fill in the values of any parameter (alternatively, on the Query menu, click "Specify Values for Template Parameters". Having done that, you have working code for your particular requirement. You can even drop templates into your favourite programmer's text editor, although you'd have to write an add-in script to present you with a dialog box to fill in the parameters like the one you see when you hit Control-Shift-M in SSMS.

What happens if the template you want isn't there? You can create your own one simply by right-clicking on the appropriate folder in Template Explorer, and selecting New | template). You can also modify the ones that SSMS itself uses when someone uses the object explorer to create a new object. You probably like your documentation headers for your object creation scripts formatted in the 'house style', so doing this will save you a lot of tedium. Also you've written your various generic views or tables types, or even complex database components, that you use again and again, Save these as templates, maybe with parameters, and then suddenly you've got productivity sewn up.

Despite all this, Microsoft gives every impression of having abandoned the implementation of Templates half way through, when some shinier bead rolled into view. As such, there are a few shortcomings. For example, there is no way of loading templates from a shared directory, or placing any new templates into source control. Team-sharing of templates is almost impossible.

Nevertheless, templates are a major reason to like SSMS and you're missing out on some productivity gains if you're not using them.

Rate

4.5 (2)

You rated this post out of 5. Change rating

Share

Share

Rate

4.5 (2)

You rated this post out of 5. Change rating