Display line numbers in SQL Server Management Studio

When you are editing in SQL Server Management Studio, it would be beneficial to display line numbers in SQL Server Management Studio, especially if you are working on a large module.

You can download SQL Server from this link.

Common Problem:

We often encounter an error message from SQL Server, which points to a particular line number within our SQL query code. It is a little frustrating to find the line number where the syntax error has occurred. In this tip, we will look at how to quickly enable line the numbers feature in SQL Server Management Studio.

Solution:

To display line numbers in SQL Server Management Studio, follow below steps:

Step1: Open SQL Server Management Studio. Navigate to Tools -> Options from the drop-down menu, as shown in the image below. Choose Options from the menu.

Toolbar Option for line numbers

Step2: In the Options dialog box on the left side panel, expand options until you can navigate to Text Editor, then expand Transact-SQL. Next, choose General, as shown in the image below.

SSMS Tools line numbers option

Step 3: After you click on General. Find the Display option from the right panel. Then check the “Line Numbers” checkbox under Display. Click on “OK”

Line Numbers Option

To apply Changes from the settings that we change, relaunch your SQL Server Management Studio and create a new query to see if the changes have been applied. Your SSMS Editor should now look like the image shown below.

SSMS Query Editor window with line numbers

When you open a new query window in SQL Server Management Studio, line numbers will now be displayed. In the sample T-SQL code shown above, line numbers are displayed. This time, it would be easier for you to trace the error in your SQL query.

Another alternative, if you don’t want this feature to be turned on and you want to go to a particular line number, you can just press CTRL+G to open the “Go To Line” dialog box enter the line number, and click OK as shown below.  

That’s it! Hope this helps!

For related SQL Server topics, you might want to check this article.

SQL Stored procedure

This article will guide you on how to create a Stored Procedure in SQL Server. Check it out!