Code navigation
Last modified: March 28, 2025
SQL scripts must be valid and error-free for the proper functioning of the Go to Definition feature. Therefore, if there are any syntax errors or other issues in your SQL code, the feature will not work.
Navigate to an object in a script
Database objects can be created using the script or from Object Explorer. When you declare an object in the script, navigation to that object will only occur within the script where it is declared, regardless of whether it exists in Object Explorer or not.
Note
When navigating to an object, the DDL of the object in the script takes precedence. This means that if the script with the required object is open in the Code Editor, and the object also exists in the Object Explorer tree, SQL Complete will prioritize navigating to that object within the script. So, if you want to navigate to the object in the Object Explorer tree, you could, for example, comment out the script where the object is declared.
Example
In the Code Editor, enter the CREATE TABLE statement to define the products table in the AdventureWorks2022 database:
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(255),
description TEXT,
);
When you hover over the products table, you’ll see the icon, indicating that the table is declared within the script.
Next, type the SELECT query:
SELECT * FROM products p;
To navigate to the object, hover over products in the SELECT statement and press F12. Alternatively, right-click the object and select Go to Definition.
SQL Complete navigates to the products table declared in the CREATE statement, while it is not highlighted in Object Explorer.
If we execute the CREATE statement and refresh Object Explorer, the table will be listed in the tree. Despite this, hovering over products in the SELECT statement and pressing F12 still navigates to the table in the CREATE statement.
Now, comment on the script where the products table has been declared. Then, hover over products in the SELECT statement and press F12 again. As you can see, the products table is now highlighted in Object Explorer but not in the Code Editor. So, if the object is present in the Object Explorer tree but has not been declared with the script, SQL Complete navigates to the object in Object Explorer.
Note
After creating the database object, refresh the Object Explorer tree. Otherwise, you may get the following error when trying to use the Go to Definition feature:
Navigate to an object in Object Explorer
SQL Complete can be used to select an object in the SSMS Object Explorer from the query window.
In the query window, right-click the object that you want to navigate to and select Go To Definition on the shortcut menu.
Alternatively, place the cursor over the object that you want to select and press F12.
SQL Complete can navigate to all objects and columns in the Object Explorer except:
- Temporary tables
- Columns in temporary tables
- Columns in linked tables
- Columns in table-valued functions
Note
This feature is available only in SSMS and is not supported in Visual Studio.
Navigate between queries
When working with large scripts, SQL Complete helps to quickly find the beginning of a SQL statement. Just press Alt+PgDn or Alt+PgUp, and the cursor will sequentially jump up or down to the beginning of each statement in the SQL document.
Navigate between BEGIN and END
The feature helps find matching BEGIN/END pairs in complex queries. Upon pressing Shift+F12, the cursor will jump up or down to the matching keywords.
Navigate between BEGIN TRY and END TRY
When working with large scripts, it is important to be able to quickly navigate between paired keywords in a SQL statement. With SQL Complete, it is easy to jump between BEGIN TRY and END TRY in a blink.
Navigate between BEGIN CATCH and END CATCH
SQL Complete helps locate matching BEGIN CATCH and END CATCH pairs in complex queries. By pressing Shift+F12, the cursor will jump up or down to the matching keywords.
Navigate between CASE and END
The CASE expressions used in statements can be quite long, and navigation between their beginnings and ends can be a daunting task. To solve this problem, use jumping between CASE and END.
Navigate between COLUMNS and VALUES in the INSERT statement
In large INSERT statements, it is often hard to determine which value corresponds to which column, and vice versa. This feature will help quickly locate the corresponding value for the current column.
Highlight the occurrences of identifiers
Once the cursor is pointed at any @CurrencyCursor, SQL Complete quickly highlights occurrences of identifiers.
To select the colors, go to SQL Complete > Options > Environment > Fonts and Colors > Display Items > Highlight Reference > Item foreground / Item background
Highlight BEGIN and END
Click a BEGIN or END keyword in the code, and SQL Complete will highlight the BEGIN/END syntax pair in your statement with gray color. This feature is designed to quickly find matching BEGIN and END statements in a query.
Highlight BEGIN TRY and END TRY
The matching BEGIN TRY and END TRY keywords will be highlighted with grey color after you click one of them. This significantly facilitates coding by helping to quickly find matching statements in long and complex queries.
Highlight BEGIN CATCH and END CATCH
Discover matching BEGIN CATCH and END CATCH pairs in complex queries. Upon clicking one of the statements, the syntax pair will be highlighted.
Highlight CASE and END
Highlighting matching CASE and END operators can significantly reduce coding time, as CASE expressions used in SQL syntax can be quite long, and navigating through them is not an easy task.
Highlight COLUMNS and VALUES in the INSERT statement
SQL Complete highlights the names of the columns and their corresponding values in the INSERT statements to help insert valid values. This feature significantly facilitates writing statements to insert records into multiple columns.
Want to find out more?
- Code navigation
- Navigate to an object in a script
- Navigate to an object in Object Explorer
- Navigate between queries
- Navigate between BEGIN and END
- Navigate between BEGIN TRY and END TRY
- Navigate between BEGIN CATCH and END CATCH
- Navigate between CASE and END
- Navigate between COLUMNS and VALUES in the INSERT statement
- Highlight the occurrences of identifiers
- Highlight BEGIN and END
- Highlight BEGIN TRY and END TRY
- Highlight BEGIN CATCH and END CATCH
- Highlight CASE and END
- Highlight COLUMNS and VALUES in the INSERT statement