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 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 reusing 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:

In order to use ApexSQL Complete’s snippets, all you need to do is type a snippet’s name in the query editor:

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

You can also either choose to create your own custom T-SQL code snippets or simply change the already existing ones in the Create new snippet and Edit snippet dialogs. Both of these dialogs contain a list of available macros which can be used in snippets. For instance, if you want 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.

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

February 24, 2015