Code Templates

WinSQL includes the ability to add custom code templates that can improve speed and consistency for writing SQL scripts. To use these templates write the starting characters of the template and then press CTRL+J.

Consider the following examples:

select *
from students
where active = 'N'
   and joindate > ::BeginingOfYear    


The objective of this query is to find all students who joined in this year but are not active. One way to accomplish this goal is to prompt the user for the actual date.

Using code templates you can just enter boy, which stands for Beginning of year, and hit CTRL+J to let WinSQL automatically insert the value for the January 1 of the current year.

select *
from students
where active = 'N'
   and joindate > boy+CTRL+J
When you click type CTRL+J, WinSQL will replace boy with the actual date and the final query will look like:

select *
from students
where active = 'N'
   and joindate > '2019-01-01'
   


TIP: CTRL+J is the default shortcut for pasting code templates. You can change this value by Customizing shortcuts under the Tools menu.

Adding new custom templates

To add new templates, click Code Templates under the Tools menu, which brings up the following screen.

This screen lists existing templates. WinSQL automatically adds a handful of templates that you can use, which you see on the screen.

Click the add button to add another template.

Navigation

Social Media

Powered by 10MinutesWeb.com