Today we will look into AUTO REPLACE option in Toad, which can also be made use of as a work around for AUTO COMPLETE of custom code snippets.
For example, typing
"SSF" automatically expands to "SELECT TOP 100 * " and
"NL" to "WITH(NOLOCK)".
It would greatly increase your productivity. To achieve this we will make use of the AUTO REPLACE option in TOAD. But the problem is that in TOAD free version, you cannot make new AUTO REPLACE entries. A work around is to manually edit the template file for AUTO REPLACE.
Follow the below steps:
|Tools > Options|
2) In the Options Window, go to Editor > Auto-Replace.
You can see the Auto Replace options available.
3) Browse to the folder: "C:\Program Files (x86)\Quest Software\Toad for SQL Server Freeware 6.5\Templates\CodeTemplates".
|Toad Auto-Replace template folder|
4) Open the SQL template file: CodeTemplate.SQL.SqlServer.xml.
You can add your auto complete snippets here.
Ex. Line 8 and 9:
<Template Title="st100">SELECT TOP 100 * </Template> <Template Title="nl">WITH(NOLOCK) </Template>
From the above example typing NL will get replaced automatically by WITH(NOLOCK).
5) Restart Toad Editor and the new changes must start to work for you.