Table of Contents


Many times in MSDN SQL Server Tools Forum users are asking how to add line numbers in SSMS or how to count the number of lines of code.


In SQL Server Management Studio there is a provision to add line numbers and it is really simple to add.

In SSMS, go to Tools - > Options ... -> Text Editor - > Transact - SQL - > General - > Display - > Line numbers (check this option to display line numbers on Query window).

Once line numbers are added, if you have T-SQL code of 1000 lines or more on your query window, the shortcut key to go particular line number is CTRL + G.

If you notice at the bottom of SSMS, you can see Ln (N), where N denotes the line number of current cursor position (as highlighted in below screenshot):

See Also

  • My other SSMS related articles