Editorials

Learn SQL Syntax from Templates

Learn SQL Syntax from Templates
Yesterday we shared how scripting objects from SQL Server Management Studio dialogs may be useful for learning SQL Syntax. You might use the table designer to complete a table definition, and then choose Script to see the SQL Syntax used to create the table, set defaults, etc.

In response to Ed writes in with another built in technique for learning SQL Syntax, and even better, a handy tool for any DBA, let alone the Accidental DBA for getting work done quickly. Ed reminds us that we can used the templates that come with SQL Server Management Studio. They provide a shell for just about any database activity you might need to perform.

ED
I’ve done the GUI thing before, but find that slows me down. What I like best, and apparently it seems that most SQL users have yet to discover, is the template browser. It’s included in SSMS but isn’t visible by default, but CTRL-ALT-T will open it. There are several templates and most if not all of what you mention scripting from the GUI are there in template form. You can double click to open one up in a new query window and then you can click that button on you SSMS tool bar that looks like an A in the upper left and a B in the lower right and a couple of arrows. It opens a dialog box that lets you substitute in your own values or accept the defaults.

You can also create your own templates (right clicking create new) and edit the templates by right clicking the template and selecting edit. I use it to keep all the scripts I run frequently, my “AAA DBA Utility Belt” (The AAAs keep it at the top for quick access). There are numerous articles about it if you Google SSMS Templates, but I haven’t run into anyone in person that used them before I told them about it.

If it’s not there Google is usually my next option.

While templates won’t necessarily provide you the details of everything you may wish to write, you may certainly fill in the gaps with scripting or searching for more information in Books Online or Google.

Don’t forget templates when you are seeking tools to help you with SQL Syntax of any sort. Do you have other tools or techniques assisting those needing to fill in the gaps in their SQL Syntax skills? Drop us an Email at btaylor@sswug.org to share your ideas.

Cheers,

Ben