Writing SQL Queries with Code Completion

SQL Complete can save your time whether you write an SQL query or format your code. This topic briefly explains how to write SQL queries using SQL Complete.

Writing a Query

For example, you need to write an SQL query like SELECT * FROM Production.Culture.

  1. Open the Query Editor window and select the AdventureWorks database in the Available Databases list on the SQL Editor toolbar. Open a new SQL document and select the AdventureWorks database from the Database list box on the SQL toolbar.
  2. Start typing: se (press Enter) * fr (press Enter)

    When you are typing, the suggestion box appears with the list of suggestions that are relevant to the typed symbols. The suggestions are filtered to display most relevant ones at the top of the list. To insert a suggestion into your code, navigate to a required one by using Up and Down arrow keys, and then press Enter.

    dbForge SQL Complete suggestion box

    The first suggestion in the list is considered the most relevant, that is why it is highlighted to speed up the insertion.

  3. Press the Space key and type cu (press Enter).

    Inserting a table name

Formatting SQL Code

SQL Complete can quickly format your SQL code depending on selected formatting options. To format your code, click Format Document on the SQL Complete menu.

You can format SQL code even if SQL Complete is disabled. Select a statement, and then click Format Document on the shortcut menu if you want to format the whole code, or click Format Selection if you want to format a required statement.

Formatting SQL Code

To disable code formatting for a specific part of the code, use the – noformat – endnoformat tags.

Inserting a Snippet

To insert a snippet to your SQL code, type first letter for a required statement in SQL editor. The statements prompt list appears. Select a statement itself, or insert a whole snippet. Snippets follow after the statements in the prompt list. Navigate a required snippet, and press ENTER.

Inserting a Snippet

dbForge SQL Complete allows navigating through the data input fields, where you can specify your own data. Use the TAB key to go forward and the TAB+SHIFT keys to go back.

Inserting a Snippet