How to code faster with SQL Server code snippets

ApexSQL Complete is a SQL Server Management Studio and Visual Studio add-in designed to speed up the coding. It completes SQL statements automatically, fills in SQL fragments, generates outlines for the SQL script structure, and speeds up coding with T-SQL code snippets.

ApexSQL Complete supports inserting ready-made static T-SQL code snippets into SQL scripts, and the primary purpose of the Snippets feature is to make reuse as easy as possible and therefore avoid wasting time on repetitive coding and inadvertent errors. The feature inserts predefined SQL fragments and replaces variables with context specific values to generate SQL at run-time.

ApexSQL Complete is configured with a set of predefined T-SQL code snippets, covering the most popular SQL constructs, which are listed in the Snippets manager. The manager also includes a code preview for each selected snippet:

The Snippets manager

In order to use ApexSQL Complete’s snippets, all that needs to be done is to type a snippet’s name in the query editor:

Snippets from the hint-list

and then press Ctrl+Enter. This action will then immediately deploy a predefined code:

Snippet in a query editor

Also, there is an option to choose to create custom T-SQL code snippets or to simply change the already existing ones in the Create new snippet and Edit snippet windows. Both of these windows contain a list of available macros which can be used in snippets. For instance, in order to create a snippet that will later be used to deploy a predefined code for a function, inserting %DATE% macro in the code body will later return the current date. Likewise, inserting %SERVER% macro will return the connection server name, %LOGIN% will show a connection login, %DB% will return a connection database, and so on. Each macro will be automatically replaced with a context specific value:

The Edit snippet windows

During routine edit operations, ApexSQL Complete can save frequently used SQL code structures as snippets, and insert context-specific values as needed. By utilizing these templates, it can significantly speed up SQL coding process and avoid typing errors.

 

February 24, 2015