SQL Server Management Studio (SSMS): Display Line Numbers

Losing your patience while writing long lines of code in SQL is understandable. SSMS includes a feature to show line numbers in your query editor to assist with this process. Instructions for SQL Server versions 2005, 2008, and 2012 are included.

By default line numbers are disabled in SQL server. However, through these steps they can be displayed with all versions of SQL Server.

Enabling line numbers option in SQL Server Management Studio (SSMS) is very useful in debugging. When errors are created, SSMS will show the line number to indicate the location of the issue. The following is an example:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'FROM'.

 

Turning on line numbers makes it easy to jump to an line within the code by specifying the specific line number.

SQL Server 2008 and 2012

1. Open SSMS.

2. Under the Tools menu, select Options.

3. When Options window appears, expand the Text-Editor section.

4. When you see above window, span the Transact-SQL option and check the box Line Numbers under Display.

5. Now when you return to your query editor, the line numbers will be enabled.

SQL Server 2005

1. Under Tools Menu, select Options.
2. When the Option window appears, expand the Text-Editor option and select All Languages.
3. Select Line Numbers.
4. Return to your query editor, line numbers would be enabled.

We will be glad to read your comments. Let us know if this really helped you to increase your productivity.

If you are a fan of displaying line numbers, you will probably want to review how to do this is in Visual Studio text editor and and Vi/Vim as well.

 

About Vishwanath Dalvi

Vishwanath Dalvi is a gifted engineer and tech enthusiast. He enjoys music, magic, movies, and gaming. When not hacking around or supporting the open source community, he is trying to overcome his phobia of dogs.
View more articles by Vishwanath Dalvi

The Conversation

Follow the reactions below and share your own thoughts.

  • http://www.24x7servermanagement.com/ 24×7 Server Management

    well done! Actually this point is very problematic but you have handled very well so in future adds more articles, Adding pictures in this blog for the viewers really helpful. Best wishes for future.

    • Vishwanath Dalvi

      Thank you for your valuable inputs, Tech-recipes.com authors always put 100% efforts for viewers.

  • vps

    I really love your blog. You write about very interesting things. Thanks for all your tips and information.

  • Kandinsky

    Thank you so much!!!