Code navigation

dbForge Studio for SQL Server offers tools for navigating SQL code, such as viewing code structure, opening object definitions, highlighting syntax elements, and moving between statements. These capabilities help optimize your workflow and improve productivity.

Note

SQL scripts must be valid and error-free. Otherwise, the features described further won’t work.

View code structure

To see the current code structure, select View > Document Outline.

You can jump to any statement in the code by clicking it in the Document Outline pane, which makes navigating large SQL documents easier.

Document Outline pane

Open an object definition

To open an object definition, right-click the object and select Go To Definition, or press F12.

Go to Definition

The object opens in Object Editor, where you can modify it visually—the underlying code is updated automatically.

Note

If an object exists only in the script and not in the database, selecting Go To Definition takes you to its declaration in the code.

Navigate between statements

Press Alt+PgUp or Alt+PgDn to move the cursor to the beginning of the previous or next SQL statement in the document.

Highlight all occurrences of a syntax element

Click a syntax element in a SQL document to highlight all its occurrences throughout the script. This feature is useful for identifying:

  • Identifiers.
  • Matching BEGIN and END keywords.
  • Matching BEGIN TRY and END TRY keywords.
  • Matching BEGIN CATCH and END CATCH keywords.
  • Matching CASE and END keywords.
  • A column and corresponding values in INSERT statements.

The default highlight color is gray.

Highlight occurrences of identifiers

Change the highlight color

1. Select Tools > Options.

2. Select Environment > Fonts and Colors.

3. Under Display items, select Highlight References.

4. Under Item background, select the color you want.

5. Click OK.

Selecting the colors

Navigate between matching keywords

You can locate matching keywords in pairs such as BEGIN/END, BEGIN TRY/END TRY, BEGIN CATCH/END CATCH, and CASE/END in SQL statements.

Place the cursor on a keyword and press Ctrl+F12 to jump to the other keyword in the pair.

For more information about CASE expressions, see Using the CASE Statement in SQL Server.

Navigate between columns and values in INSERT statements

In large INSERT statements, the Studio helps you identify which values correspond to which column, and vice versa.

Place the cursor on a column name or value and press Ctrl+F12 to move the cursor between the column name and its corresponding values.

Navigate across scroll bar annotations

To identify rows with validation errors or rows that are currently focused or selected, use scrollbar annotations. These colored markers appear on the vertical scroll bar and help you navigate the document by indicating the locations of the following items:

  • Changes: Modified rows, including unsaved and saved changes.
  • Marks: Bookmarks, breakpoints, and identifier occurrences.
  • Errors and warnings: Server and parsing syntax errors, warnings, code analysis errors and warnings.
  • Caret position: Current caret position in a SQL Editor.

Example: Navigate across scroll bar annotations

Enable scroll bar annotations

1. In the top menu, select Tools > Options.

2. Navigate to Text Editor > Scroll Bar.

3. Select Show annotation over vertical scroll bar, then select annotations you want to display on the vertical scroll bar:

  • Show changes – Marks saved and unsaved changes.
  • Show marks – Marks identifier occurrences, breakpoints, and bookmarks.
  • Show errors and warnings – Marks errors and warnings.
  • Show caret position – Marks a caret position in a script.

Note

By default, all options are selected.

When Show annotations over vertical scroll bar isn’t selected, the other options on the Scroll Bar page are unavailable.

4. Click OK to save the changes.

Change a scroll bar annotation color

By default, a scroll bar annotation color matches the color of the object that created it. You can change the annotation color in the Options dialog.

To change a scroll bar annotation color:

1. In the top menu, select Tools > Options.

2. Navigate to Environment > Font and Colors.

3. Under Show settings for, select Text Editor.

4. Configure the settings.

5. Click OK to save the changes.

Default colors for scroll bar annotations

The table describes scroll bar annotations for the Changes category.

Default color Default annotation Description
Unsaved changes Unsaved changes Specifies the annotations on the left side of the scroll bar to indicate script changes that have not yet been saved.
Saved changes Saved changes Specifies the annotations on the left side of the scroll bar to indicate script changes that have been saved.

Note

You can’t change the colors of saved and unsaved changes.

The table describes scroll bar annotations for the Marks category.

Default color Default annotation Description
Highlight references Highlight references Specifies the annotations in the middle of the scroll bar to indicate identifier occurrences.
Breakpoints Breakpoints Specifies the annotations in the middle of the scroll bar to indicate breakpoints.
Bookmarks Bookmarks Specifies the annotations in the middle of the scroll bar to indicate bookmarks.

The table describes scroll bar annotations for the Errors and warnings category.

Default color Default annotation Description
Server errors Server errors Specifies the annotations on the right side of the scroll bar to indicate server syntax errors.
Parsing syntax errors Syntax errors Specifies the annotations on the right side of the scroll bar to indicate parsing syntax errors.
Warnings Warnings Specifies the annotations on the right side of the scroll bar to indicate warnings, including warnings sent by Code Analyzer.
Code analysis error Code analysis errors Specifies the annotations on the right side of the scroll bar to indicate errors found by Code Analyzer.

The table describes scroll bar annotations for the Caret position category.

Default color Scroll bar annotation Description
Caret Caret Specifies the scroll bar annotation as a horizontal line that aligns with a caret position in a script.

Note

You can’t change the color for a caret.