How to create and edit SQL queries in dbForge Studio

To create a query:

  1. Create a server connection. For more information about how to create a server connection see Connecting to a Database.
  2. On the Start page, click SQL Development and then click SQL Editor. Alternatively, click New SQL on the Standard toolbar or press CTRL+N. An empty SQL document opens.
  3. Type a query to a database.
  4. Click Execute or press F5 to see the query results.

dbForge Studio SQL editor provides many features that make it easier for you to write and manage your code. Let’s explore some Intellisense features that assist you while coding.

Coding Technique Example:

To show you some dbForge Studio Intellisense features, let us perform a query where we need to display all the employees’ addresses from the AdventureWorks2012 database who are registered in the Newton city.

  1. Open the SQL Editor.
  2. Start typing the select statement. Enter first three letters “sel”. dbForge Studio shows you the list of the relevant keywords and snippets. You can select the SELECT keyword from the list and press ENTER. The keyword appears in the SQL editor.

    Select Statement

    You can also use the select statement fragment. Enter the ‘ssf’ letters, and then press the TAB button. In this case the SELECT * FROM statement appears in the SQL editor.

    ssf

  3. Specify the table you want to retrieve data from. Start typing the first letters of the table name, and dbForge Studio shows you a list of valid tables from the AdventureWorks2012 database. If you continue typing characters, the list is filtered to include only the tables that begin with those characters. After selecting an item, you can insert it into your code by pressing TAB or ENTER. dbForge Studio also shows a quick info for every highlighted item in the list. It allows you to see the object structure immediately.

    Address Properties

    The Address table comes the first in the list, so choose it and press TAB or ENTER to insert it into the SQL editor. dbForge Studio assigns the alias for the Address table automatically.

  4. We need to select address categories that are stored in separate tables. In a similar way, either type or insert the JOIN keyword and press the SPACE key. dbForge Studio shows you all available solutions to implement JOIN. Select a required statement and press ENTER.

    Join Statement

  5. Use the WHERE statement to finish the query creating where we need to display the addresses from the Newton city only. Type the statement, use the prompt to choose the required item to put under the condition, and press ENTER.

    Where Statement

    Specify the condition where a.City = ‘Newton’.

    Where Statement 2

  6. To format the query text, press CTRL + K, D combination, or choose the Advanced option, on the Edit menu, and click Format Document.

    Formatting Query

  7. To expand the table columns, place the cursor after the asterisk character and press TAB.

    Tab Feature

    There is no need to retrieve all the columns from the Address table, so we can leave only required ones.

  8. Now we can execute the query to see results. To do so, click the Execute button on the Debug toolbar, or press F5.

    Result Set

We got what we wanted.

As you can see, the Intellisense feature provided by dbForge Studio allows you to create complex queries in a few keystrokes.

Download dbForge Studio for SQL Server and try it absolutely free for 30 days!

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?