By default, SQL Server Management Studio (SSMS) does not show line numbers in the query editor. This can be frustrating when debugging errors (which often mention a specific line number) or when working in teams.
The good news: enabling line numbers is quick and easy.
🔧 Steps to Enable Line Numbers in SSMS
- In SSMS, go to the top menu: Tools > Options.
- In the Options window, expand: Text Editor > Transact-SQL > General.
- Check the box Line numbers.
- Click OK.
Now, every query window will display line numbers on the left margin.
🖥️ Example
Before:
SELECT * FROM Customers
WHERE Country = 'USA'
ORDER BY CustomerID;
After enabling line numbers, you’ll see:
1 SELECT * FROM Customers
2 WHERE Country = 'USA'
3 ORDER BY CustomerID;
✅ Why It Helps
- Debugging: Error messages that reference line numbers are much easier to trace.
- Collaboration: Easier to discuss code with teammates (“Check line 45”).
- Navigation: Quickly spot sections of large scripts.
Enabling line numbers is a simple tweak that makes coding in SSMS much smoother. If you often debug or write long scripts, it’s worth turning on.

