Line numbers can be very helpful when writing/debugging code in SQL Server Management Studio. Below are the simple steps to turn on line numbering in the query window.
From the menu at the top, select Tools –> Options
From the list on the left, choose Text Editor and then All Languages. Then select the Line numbers check box on the right. Choose OK to save your settings.