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.
Note
The actual document look may slightly vary from the image above, depending on the product you use.
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.
To switch to a specific view:
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.
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:
The query execution results will look as follows:
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.
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.
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.
To change the main document view, use the Swap main and additional documents views button () to swap the main view and active additional view.
In the combined layout you can see only one view at a time.
In order to switch between Text and Data, click the corresponding buttons at the bottom of the screen.
There are three ways to select a block of SQL code:
Shift + navigational keys, Page up, Page down, Home, and End
Shift + Alt + navigational keys, Page up, Page down, Home, and End
Using the mouse
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.
In order to navigate the bookmarks:
Click the Move the caret to the previous bookmark button or use the Ctrl+K, Ctrl+P hot keys.
Click the Move the caret to the next bookmark button or use the Ctrl+K, Ctrl+N hot keys.
To delete all bookmarks in the current document, click or press Ctrl+K, L.
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.
The status bar contains the most important information regarding the current connection and query execution.
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.
Query Execution Status | Execution Time | Host (Server version) | Username | Selected Database |
To comment on a part of the SQL code, select it and click Comment out the selected lines. Alternatively, press CTRL+K, C
To uncomment a section, select it and click Uncomment the selected lines (or use the CTRL+K, U hot keys).