Display Line Numbers in SQL Server Query Window

Introduction

You often see SQL Server code with or without line numbers. You might receive an error message when you try to add line numbers with SQL code. This behavior is by default and happens when we try to add line numbers manually. In this article, we look at how to enable line numbers in the SQL Server Query Window. 

Let us see how to enable or disable the display of line numbers in the SQL Server Query Window. The following defines some simple steps to do that.

Step 1. On the Tools menu, click "Options."

Tool-Menu-in-SQL-Server.jpg

Step 2. When we click on the option, the Options window will be displayed:

Tool-Menu-with-option-in-SQL-Server.jpg

Step 3. In the Options pop-up box, select "Text Editor" and expand it and select "Transact-SQL," expand it and select "General."

Or

"Text Editor" -> "Transact-SQL" -> "General"

Tool-Menu-with-Transact-SQL-option-in-SQL-Server.jpg

Step 4. In the General page's right-side panel, you must select the "Line numbers" check box under the "Display" section, as shown in the following image.

Line-number-in-SQL-Server.jpg

Step 5. Now click "OK" to save the changes and test them.

Line-number-test-in-SQL-Server.jpg

 

Step 6. Uncheck the check box of the line number that prevents the line number.

Conclusion

This article taught us how to enable line numbers in the SQL Server Query Window with code example.


Similar Articles