Writing SQL Queries with Code Completion

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

Writing a Query

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

  1. 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 dbForge Studio suggestion box

    Note
    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

dbForge Studio can quickly format your SQL code depending on selected formatting options. To format your code, click Format Document on the Text toolbar.

You can format SQL code even if code completion 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. Alternatively, click Insert Snippet on the shortcut menu.

Inserting a Snippet

dbForge dbForge Studio 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.