Quick SSMS Tip: Map Mode for Code–#SQLNewBlogger

Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

In recent versions of SSMS, there’s been an addition to the query windows that I find helpful and useful. This is the map mode for code, and it means that when you have a large script, you can get a quick view of where you are in the file, and where you code is located.

First, turning this on. In the Options for SSMS, select the Text Editor section on the left, then expand the All Languages item. There is a Scroll Bars section to select. When you pick this, on the right you will see the Behavior section near the bottom. The default is bar mode, but you can switch this to map mode.

2020-07-23 16_44_26-Window

When you do that, if you open a script that is bigger than your query window, you will see a map of the code, along with a light colored bar that shows where you are in the code.

In the image below, Glenn Berry’s diagnostic script is open, and  I have actual code near the middle of my screen, and on the right, you can see the pink just at the bottom of the oval that’s lighter in color than the map.

2020-07-24 10_24_27-Window

This is a little hard to describe, but if you turn this on and experiment, you’ll get an idea of what happens.

Let me add some blank links to this script. When I do that, I can see the map expand with some gray spaces near the top.

2020-07-24 10_46_23-Window

You can also get a preview of code by putting the cursor on the map to the right. Below I’ve put the cursor on the right side, above the current location in the query window. I see a preview of the code, while I see the locator bar below the preview, showing me where I am in the code file.

2020-07-24 10_47_33-Window

Map mode is an interesting way to manage large code files, which sometimes occur in stored procedures and complex queries. While I would hope that most people don’t have hundreds of lines of code in any one file, I do know some do. Map mode can help.

SQLNewBlogger

This was a question someone asked me in a presentation. It took me almost as long to type an explanation as it did to take a few screenshots. Adding a little text made this a 10 minute effort.

This is the type of thing that you can do, showing how this might help you with some code that is complex and harder to navigate. In addition, this is a nice way to show you are honing your craft and learning to use your tools.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , , . Bookmark the permalink.

1 Response to Quick SSMS Tip: Map Mode for Code–#SQLNewBlogger

  1. Yes, map mode is awesome. One behavioral difference to note: left-clicking within the scroll bar when using map mode will go directly to that location. The default behavior (i.e. what you get when using bar mode) is page up / page down, depending on if the click was above or below the current position.

    If interested, I have a detailed look at “map mode”, including what the various color dots on the left side of the scroll bar represent, here:

    https://sqlquantumleap.com/2017/07/17/ssms-tip-1-annotations-and-map-mode-for-vertical-scroll-bar/

    Take care,
    Solomon…

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.