Easier way to read your TSQL code in SSMS with word wrap feature

By:   |   Comments (6)   |   Related: > SQL Server Management Studio Configuration


Problem

While creating T-SQL scripts with lengthy T-SQL lines you have one of two options; either use the horizontal scroll bar or create line breaks at various points to make the line readable without having to use the scroll bar. Scrolling or having to break the lines of code takes time away from paying attention to coding. It would be nice if there was a word wrap option or something similar. Are there are any options in SQL Server Management Studio to handle word wrap?

Solution

Line many new features in SQL Server Management Studio (SSMS), Microsoft has also addressed the word wrap issue. You can easily turn on this feature for the SSMS query pane, just follow the steps below to turn on this feature..

From the SSMS menus select "Tools" and then "Options"

options

In the "Options" window select "All Languages" on the left side. On the right side under Settings there is a "Word wrap" option which is unchecked by default as shown below.

use wo1

Check the check box for "Word wrap" and this will enable word wrap for your query pane. Another option under word wrap is "Show visual glyphs for word wrap" this option if checked places a visual mark for each line where the word wrap is applied.

word wrap

Without either option enabled the below image shows what is displayed in SSMS.

create procedure

After turning on both options ("Word wrap" and "Show visual glyphs for word wrap") your long query lines are displayed as follows. The highlighted characters below show the "visual glyphs" where the word wrap has been applied.

create procedure
Next Steps
  • With the word wrap option turned on you can focus more on your coding, logic and flow of your T-SQL script without having to scroll. So turn it on along with visual glyphs and get rid of scrolling and having to create manual line breaks.
  • There are two other options under "Text Editor" where you can also apply this feature. If you select "All Languages" and turn on these features this will also apply to these two features as well.
    • "Plain Text" - this applies to other documents such as text documents
    • "XML" - this applies to XML documents


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Atif Shehzad Atif Shehzad is a passionate SQL Server DBA, technical reviewer and article author.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips



Comments For This Article




Wednesday, September 22, 2021 - 8:37:01 AM - Ronen Ariely Back To Top (89250)
It is good solution, but I prefer the option of adding "toggle word wrap" button and not change the editor default. There is no reason to change the default behavior for the editor - This might make some script much harder to read: https://ariely.info/Blog/tabid/83/EntryId/299/SSMS-tips-word-wrap.aspx

Saturday, February 10, 2018 - 2:38:52 AM - Dharmendra Kumar Pandit Back To Top (75172)

 

 Thank you. Its helpful


Saturday, January 31, 2015 - 12:17:30 AM - Ritesh Kc Back To Top (36125)

thankful for me....


Wednesday, March 28, 2012 - 3:57:29 PM - Jay Back To Top (16685)

This was very helpful


Monday, November 10, 2008 - 11:36:37 PM - @tif Back To Top (2188)

 eliassal, i have tested for said problems through many scenarios. Fresh installation of SQL server without SP, with SP2, with SP3 and by reinstalling management tools after SP3. But i have found it Ok. Please tell the edition and sp of your SQL Server.

Regards


Monday, November 10, 2008 - 1:29:41 PM - eliassal Back To Top (2185)

Hi, I followed instructions but nothing is happening or changing in my query window which stills goes beyond the scroll bars and doesnt wrap.

 

Thansk for your time















get free sql tips
agree to terms