As a developer you may have often encounter errors while debugging TSQL code. SQL Server will show you an error message referencing you to a particular line number where the syntax error has occurred. This tip explains how to enable Line Number feature in SQL Server Management Studio (SSMS). The step mentioned in this tip is applicable to all versions of SQL Server Management Studio starting SQL Server 2005.
How to Display Line Numbers in SQL Server Management Studio (SSMS)
In SQL Server Management Studio (SSMS) by default display line number feature is disabled. However, you can easily enable this feature by following the steps mentioned in this tip.
1. Open SQL Server Management Studio. Click Tools ⇒ Options as shown in the below snippet.
2. In the Options dialog box on the left side pane expand the Text Editor and then expand Transact-SQL. Select General option as shown in the below snippet.
Top Trending SQL Server DBA and Developer Articles and Tips
- How to Repair Suspect Database in SQL Server
- How to Enable Dedicated Administrator Connection in SQL Server
- How to Configuring Database Instant File Initialization Feature of SQL Server
- How to Backup and Restore Resource Database in SQL Server
- How to Start SQL Server in Single User Mode?
- How to Start SQL Server with Minimal Configuration
- How to Detect Virtual Log Files in SQL Server Transaction Log File
- How to Identify the Location of Resource Database in SQL Server
- How to Disable an Index in SQL Server
- How to Monitor Transaction Log File Usage in SQL Server
- How to Connect to SQL Server When all System Administrators are Locked Out
3. In General Page, under Display select the Check Box next to Line Numbers as shown in the above snippet and click OK. Select “Word Wrap” option under Settings if you would like to wrap the TSQL code. Once you have enabled this feature in SSMS every time you open a New Query window it will Display Line Numbers.
Important Note: Whenever you encounter an error while running the TSQL Code you can double click the error message in the messages tab and SSMS takes you to the line which is wrongly written.
- Recommend you to explore other features in SQL Server Management Studio.