Have ever tried to debug a chunk of TSQL code (like a stored procedure) and found yourself trying to figure out which TSQL statement is at a particular line number? By default, SQL Server Management Studio (SSMS) doesn’t display numbers. But that is only the default, you can change it.
To allow your Query window to display line numbers all you need to do is go to the “Tools” item on the menu and then click on the “Options…” item:
Tools/Options
When you do that the “Options” screen will be displayed. On this screen expand the “Text Editor” item, the “All Languages” item, then the “General” item. Under the “Settings” item enable the line numbers, by checking the “Line numbers” item. To save this setting click on the “OK” button.
Options Screen
By doing the above you will now get line numbers in all of your query windows that are open, or any new query windows that you might open.