SQL Document overview

When working with databases, a crucial aspect of your interaction involves writing and executing SQL queries. In the dbForge product line, the SQL document plays a pivotal role that gives you an opportunity to create SQL statements and subsequently execute them against the connected database server.

The guide explores the following topics:

To create a new SQL Document:

1. On the standard toolbar, click New SQL.

2. In the Connect to Server that opens, choose the server you want to connect to and click Connect.

The empty SQL document opens where you can insert and update a SQL statement.

SQL document overview

Each SQL document includes different representations of the content: Text and Data document views.

  • 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.

Document views

To switch to a specific view:

  • Click the view name at 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.

Represent query execution results

In SQL Editor, the query execution results can be represented in two ways: Grid (default state) and Card Views.

Grid View

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

Query execution results in grid format

Card View

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

Results as Cards

Document layout

SQL document has two types of view layout: Split Layout (default layout) and Combined Layout. To switch document layout, use the appropriate options at the bottom-right corner of the document.

Document Layout

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 the main view, which is aligned to the top of the document viewport, and additional views, which are displayed at the bottom area of the document viewport.

To swap the main view and active additional view, click Swap Layouts Swap main and additional document views at the bottom of the SQL document.

Split Layout

Combined Layout

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

Combined Layout

To switch between the document views, click Text or Data at the bottom of the SQL document.

Text selection

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

  • Use the Shift + navigational keys, Page up, Page down, Home, and End.
  • Use the Shift + Alt + navigational keys, Page up, Page down, Home, and End.
  • Use the mouse.

Bookmarks

dbForge Event Profiler allows adding a bookmark to any part of your SQL document. This feature saves a particular line in the code and the cursor position.

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

Bookmarks

To navigate the bookmarks:

  • Click Previous Bookmark Move the caret to the previous bookmark or use the Ctrl+K, Ctrl+P keyboard shortcut.
  • Click Next Bookmarks Move the caret to the next bookmark or use the Ctrl+K, Ctrl+N keyboard shortcut.

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

Code folding

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

Code Folding

Status bar

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

Status Bar

where:

  • Development is an environment category
  • Connected is a connection status
  • DBFSQLSRV\SQL2022(16) is a host (server version)
  • sa is a username
  • AdventureWorks2022 is a selected database

When you execute a query, the query execution status and the query execution time will be displayed in the status bar.

Status Bar Query Executed

  • Development is an environment category
  • Query executed successfully is a query execution status
  • 00:00:00.438 is the execution time
  • DBFSQLSRV\SQL2022(16) is a host (server version)
  • sa is a username
  • AdventureWorks2022 is a selected database

Comment the code

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

Comment

To uncomment a section, select it and click Uncomment the selected lines on the standard toolbar or use the CTRL+K, U keyboard shortcut.

Uncomment