SQL Editor Overview

Most of the time you interact with a database by writing and executing SQL queries. In this way, SQL document is an essential part of every database tool in the dbForge product line. It is a place where you create SQL statements in order to run them against a database server. This topic gives you an overview of SQL document layout, views, and functions.

To create a new SQL Document, click New SQL on the Standard toolbar.

The following image is an example of an SQL document.

Sql Document

Note
The actual document look may slightly vary from the image above, depending on the product you use.

SQL Document overview

Each SQL document includes different representations of the content. They are called document views. On the above screenshot, you can see two document views: Text and Data.

  • Text view comprises the SQL Editor which allows you to write SQL statements.
  • Data view, typically shown after a query is executed, comprises the Data Editor that displays the result sets returned by a database server.

To switch to a specific view:

  • Click a button with a view name on the bottom-panel of the document.
  • Right-click the bottom panel of the document to open the shortcut menu and select a view from the list.

Representing query execution results

The query execution results can be represented in two ways - in the Grid and Card Views.

1. To represent results as a grid, click the Switch to Grid View button on the SQL toolbar. The following image represents a sample of query execution results in the grid format.

Results as Grid

Moreover, the grid view allows grouping the execution results by box. To test the feature, click Show Group by Box and drag a column header to the designated area:

Results as Grid: Group by Box

The query execution results will look as follows:

Results as Grid: Group by Box

2. To view the results as cards, click the Switch to Card View button on the SQL toolbar. The following image represents a sample of query execution results in the card format.

Results as Cards

Document layout

SQL document has two types of view layout: Split Layout and Combined Layout. To switch document layout use the corresponding buttons at the bottom-right corner of the document.

Split layout

In the split layout, a document is divided into two horizontal areas:

1. Text - the SQL document you are working with.

2. Data - the query execution result.

A document has one prominent (main) view which is aligned to the top of the document viewport. Other views are called additional, they are displayed in the bottom area of the document viewport.

Split Layout

To change the main document view, use the Swap main and additional documents views button (Swap Layouts) to swap the main view and active additional view.

Combined layout

In the combined layout you can see only one view at a time.

Combined Layout

In order to switch between Text and Data, click the corresponding buttons at the bottom of the screen.

Text selection

There are three ways to select a block of SQL code:

  1. Shift + navigational keys, Page up, Page down, Home, and End

  2. Shift + Alt + navigational keys, Page up, Page down, Home, and End

  3. Using the mouse

Bookmarks

Query Builder for SQL Server allows adding a bookmark to any part of your SQL document. This feature saves not only a particular line in the code but also the cursor position.

To add a bookmark, click Toggle a bookmark on the current line or press Ctrl+K, K.

Bookmarks

In order to navigate the bookmarks:

  • Click the Move the caret to the previous bookmark button Previous Bookmark or use the Ctrl+K, Ctrl+P hot keys.

  • Click the Move the caret to the next bookmark button Next Bookmarks or use the Ctrl+K, Ctrl+N hot keys.

To delete all bookmarks in the current document, click Clear Bookmarks or press Ctrl+K, L.

Code folding

In case you are working with a large script, you might need to collapse some of the clauses for convenience. If you hover over the collapsed clause, you will see its content.

Code Folding

Status bar

The status bar contains the most important information regarding the current connection and query execution.

Status Bar

Connection Status Host (Server version) Username Selected Database

When you execute a query, you will see query execution status instead of the connection status. Also, the query execution time will be displayed in the status bar.

Status Bar Query Executed

Query Execution Status Execution Time Host (Server version) Username Selected Database

Commenting the code

To comment on a part of the SQL code, select it and click Comment out the selected lines. Alternatively, press CTRL+K, C

Comment

To uncomment a section, select it and click Uncomment the selected lines (or use the CTRL+K, U hot keys).

Uncomment

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Query Builder for SQL Server.
Request a demo

Request a demo

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