Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

SQL Server 2016 Management Studio Enhancements - Part 2

$
0
0

By:Rajendra Gupta || Related Tips:More > SQL Server Management Studio

Problem

In my previous tip SQL Server 2016 Management Studio Enhancements we have seen some of the new SQL Server Management Studio (SSMS) features and improvements. In this tip we will explore some more enhancements in SSMS.

Solution

In myprevious tip we have explored the following:

Highlighting the current line in SQL Server Management Studio Searching for options in SQL Server Management Studio SQL Server Management Studio Quick Launch SQL Server Management Studio Tabs Customization Pinning Tabs in SQL Server Management Studio

Now we will explore these features:

Scroll bar enhancements Filtering in the Databases node in SSMS Enhancements in offline database management studio Saving open queries in SQL Server Management Studio (SSMS)

Note: In this tip I am using the SQL Server Management Studio August release version 13.0.15700.28 with SQL Server 2016 version Microsoft SQL Server 2016 (RTM) - 13.0.1601.5 (X64).


SQL Server 2016 Management Studio Enhancements - Part 2
SQL Server Management Studio Scroll Bar Enhancements

SQL Server 2016 Management Studio provides great enhancements for the vertical scroll bars with features like visuals, colors and tool tips. To open the scroll bar properties go to Tools > Options > Text Editor > All Languages > Scroll Bars tab or use thequick launch to search.


SQL Server 2016 Management Studio Enhancements - Part 2

We can also open it by right clicking on the vertical scroll bar in a query window and select the Scroll Bar Properties... as shown below.


SQL Server 2016 Management Studio Enhancements - Part 2

These are the scroll bar options:


SQL Server 2016 Management Studio Enhancements - Part 2

As we can see in the scroll bar properties, there are four annotation options: Show changes , Show marks , Show errors , Show caret position . I opened a query and we will look at each of these below.

Show changes

This annotation tracks all changes in the script. The green color on the right indicates that no changes were made in the script.


SQL Server 2016 Management Studio Enhancements - Part 2

If we made any changes in the script it will appear yellow in the vertical scroll bar.


SQL Server 2016 Management Studio Enhancements - Part 2
Show Errors

If there are any errors in the script, it will show as red in the vertical scroll bar.


SQL Server 2016 Management Studio Enhancements - Part 2
Show caret position

This displays the current location of the cursor in relation to the entire script. It is displayed as a blue line in the right vertical scroll bar.


SQL Server 2016 Management Studio Enhancements - Part 2
Show marks

This shows the locations of breakpoints in the script.


SQL Server 2016 Management Studio Enhancements - Part 2

The vertical scroll bar has two modes as we can see in the Behavior section of scroll bar properties.


SQL Server 2016 Management Studio Enhancements - Part 2

The default value for vertical scroll bar behavior is Bar mode which can be seen in the above pictures. If we change it to Map mode, the vertical bar looks like this:


SQL Server 2016 Management Studio Enhancements - Part 2

In the map mode, we have the Show Preview Tooltip option under the Behavior section. When this is selected a code preview appears when we hover over that portion of the vertical scroll bar.


SQL Server 2016 Management Studio Enhancements - Part 2

This is actually a good enhancement specially in the case of large queries. We can simply see a preview of part of the script just by hovering over the vertical bar. If we wish to move to that portion of the script, click on it or right click on the vertical scroll bar and select Scroll Here and it will move to that location.


SQL Server 2016 Management Studio Enhancements - Part 2

We can also control the width of vertical map scroll bar by selecting the source overview as Off, Narrow, Medium and Wide.


SQL Server 2016 Management Studio Enhancements - Part 2

Here we can see the differences of each of these options.


SQL Server 2016 Management Studio Enhancements - Part 2

The Map vertical scroll bar mode also supports the annotations shown above.

Filtering in the Databases node of SSMS

SQL Server Management Studio now supports filtering databases in the SSMS object explorer. This filter can be done with the Database Name, Owner and Creation Date. To filter the database in SSMS, right click on Databases > Filter > Filter Settings.


SQL Server 2016 Management Studio Enhancements - Part 2

Suppose we want to filter the database where database name is like "wide".


SQL Server 2016 Management Studio Enhancements - Part 2

After applying the filter, we can see only databases having name like wide (i.e. WideWorldImporters and WideWorldImportersDW). The database node also shows that a filter is applied by showing (filtered) next to the Databases folder.


SQL Server 2016 Management Studio Enhancements - Part 2

The filter options for Name include Equals, Contains and Does not contain. For Owner it includes Equals, Contains and Does not equal. For Create Date there are bunch of different options.


SQL Server 2016 Management Studio Enhancements - Part 2

Suppose we want to filter the database name where owner equals 'sa':


SQL Server 2016 Management Studio Enhancements - Part 2

We now only see databases where owner is "sa" as shown below.


SQL Server 2016 Management Studio Enhancements - Part 2

If we want to remove the filter, right click on Databases > Filter > Remove Filter.

Enhancements for Taking a Database Offline in SSMS

Suppose we want to take a database offline using Management Studio. In the past if there were active connections the database will continue waiting for the sessions to be released. SQL Server 2016 Management Studio now supports a Drop All Active Connections option as shown below.

Suppose we want to take database the 'WideWorldImporters' which has active connections, right click the database and select Tasks > Take Offline. This will open this dialog box and we can see in the Message we have 1 active connection.


SQL Server 2016 Management Studio Enhancements - Part 2

We can click on the check box for Drop All Active Connections and it will now proceed without waiting and database will go offline once we click OK.


SQL Server 2016 Management Studio Enhancements - Part 2
Option to skip prompt for saving opened T-SQL query windows Normally if we are closing new query windows, SSMS prompts whether we w

Viewing all articles
Browse latest Browse all 3160

Trending Articles