If you ever have long scripts in SQL Server Management Studio and need to refer to a particular line, it can be helpful to have line numbers shown. This is even more useful if you ever need to write a set of instructions for someone on how to modify a query, or if you are trying to describe how a query works.
Instead of having a query like this:
In Tools, then Options, then Text Editor, then Transact-SQL, on the General tab, there is an option for Line Numbers:
Once that’s enabled, the query windows look like this:
The line numbers go in a separate margin. Note that all lines are numbered, unrelated to whether or not they contain an individual SQL statement.
If you have a long script and you need to quickly, reposition the cursor, note that you can also go directly to a line number. On the Edit menu, you can see that Ctrl-G is the shortcut for Go To.
Hitting Ctrl-G pops up a dialog and asks me for a line number:
Then takes me straight there. Note that in the dialog, the maximum line number is shown.