Chapter 1
Getting started with SQL Server tools

This chapter provides information about where to find many of the Microsoft tools used to manage and work with the Microsoft SQL Server platform. It also walks you through the installation, configuration, and basic utility of each tool.

The chapter is divided into five distinct sections:

  • Installation Center

    • The Planning Tab

    • The Installation Tab

  • Tools installed with the Database Engine

  • SQL Server Management Tools

  • SQL Server Data Tools

SQL Server setup

You can install SQL Server 2017 natively on Windows and Linux. For development and testing environments, you can install SQL Server with Docker container images on Windows, Linux, and macOS.

The following section covers installing SQL Server natively on Microsoft Windows.

Image For more details on how to set up and configure SQL Server, read Chapter 4.

Installing SQL Server by using the Installation Center

SQL Server Installation Center is the application that you use to install and add features to an instance of SQL Server. As illustrated in Figure 1-1, it can also serve as a launch point for downloading the installation packages for SQL Server Upgrade Advisor, SQL Server Management Tools, SQL Server Reporting Services, and SQL Server Data Tools.

Image

Figure 1-1 Installation Center components. Downloadable tools have a cloud outline.

It might seem a bit confusing, but on the Installation tab, the installers for SQL Server Reporting Services, SQL Server Management Tools, and SQL Server Data Tools, are merely links that redirect to a download location on the Microsoft website for each of these components’ installation files. You also can download and install the tools independently without using Installation Center.

The same is true for the Planning tab, on which the Upgrade Advisor (also known as the Data Migration Assistant) is simply a launch point for a continually updated .MSI file that you can download.

Inside OUT

How do I install SQL Server 2017 on Linux?

SQL Server is fully supported on Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Ubuntu, using the built-in package manager for each distribution.

The main SQL Server package is the Database Engine. You can install the command-line tools, SQL Server Agent, Full-Text Search, and SQL Server Integration Services as optional packages.

For more information about installing SQL Server on Linux, visit Microsoft Docs at https://docs.microsoft.com/sql/linux/sql-server-linux-setup.

Planning before an upgrade or installation

When you first start the SQL Server Installation Center, it opens with the Planning tab preselected. This tab has two tools that you might find useful before installing or upgrading a SQL Server instance to SQL Server 2017: Configuration Checker and Upgrade Advisor.

Configuration Checker

The Configuration Checker tool checks for conditions that might prevent a successful SQL Server 2017 installation. When you click the Configuration Checker, a wizard runs against the local computer. There is no option to choose an alternate computer location. The wizard returns an HTML report listing all 13 installation requirement rules (facets) and the results of each test. Nine of these rules are universal to all Windows Configurations, and you can easily remedy most of them.

  1. FacetDomainControllerCheck. We recommend that you do not install SQL Server 2017 on a Domain Controller. There are two reasons for this. First, it can compromise the security of both Active Directory and the SQL Server instance. Second, it can cause resource contention between the two services.

  2. FacetWOW64PlatformCheck. Windows operating systems must be 64-bit to support a SQL Server 2017 installation.

  3. MediaPathLength. The path for the location from which SQL Server 2017 is being installed must be fewer than 260 characters in length.

  4. NoRebootPackage. The correct .NET Frameworks must already be installed.

  5. RebootRequiredCheck. No installation reboots can be pending.

  6. SetupCompatibilityCheck. No subsequent incompatible versions of SQL Server can be installed on the computer.

  7. SSMS_IsInternetConnected. Verifies that the computer is connected to the internet. This is required for validating a certificate when a .NET application starts.

  8. ThreadHasAdminPrivilegeCheck. The account running the setup file must have Local Administrator rights on the computer.

  9. WmiServiceStateCheck. Checks whether the Windows Management Instrumentation (WMI) service is started and running on the computer.

Image You can find the most up-to-date Rules Documentation at http://go.microsoft.com/fwlink/?LinkID=398124.

Upgrade Advisor

The Upgrade Advisor link on the Planning tab of Installation Center downloads the Data Migration Assistant installation package.

This application is really two tools in one, which you can use to create two project types:

  • An assessment of upgrade or migration readiness

  • A migration of data between versions of SQL Server and/or Microsoft Azure SQL Database

In both cases, the Source Server must be a SQL Server instance. The target server choices for all three Target Server Types accommodate both Assessment and Migration, as shown in Table 1-1.

Table 1-1 Data Migration Assistant assessment matrix

Target server type

Assessment

Migration

Azure SQL Database

X

X

SQL Server

X

X

SQL Server on Azure Virtual Machines

X

X

Assessment The Assessment project type of the Data Migration Assistant detects database-specific compatibility issues between origin and destination SQL Server versions in the course of pre-upgrade discovery. It is common between versions for there to be deprecation and feature differences, and this is especially true if the Target Server Type is an Azure SQL database. If not addressed, some of these items might affect database functionality during or post upgrade. The tool neatly outlines all findings and makes recommendations.

The Assessment project type examines the following aspects of upgrading SQL Server:

  • Database compatibility. Looks at deprecated features and functionality issues that could be “show stoppers.”

  • Feature parity. Identifies unsupported or partially supported features and functions that applications using the database might rely on. For example, if you plan to move to Azure SQL Database, these include Cross Database Queries, Server-Scoped Logon Triggers, and Trace Flags.

  • Benefits from new features. This feature is expected sometime soon and is not currently available.

Image You can find more information online by searching for “Discontinued Database Engine Functionality in SQL Server XXXX,” where XXXX is your Source SQL Server platform.

Migration Using the Migration project type of the Data Migration Assistant, an administrator can move a database’s schema, data, and noncontained objects from a source server to a destination server. The wizard works by providing a user with the option to select a Source and Destination Server and to choose one or more databases for migration.

Moving to SQL Server For SQL Server migrations, there must be a backup location that is accessible by both the source and destination servers, generally a UNC path. If this is a network location, the service running the source SQL Server instance must have write permissions for the directory. In addition, the service account running the destination SQL Server instance must have read permissions to the same network location.

If this poses a challenge, there is a check box labeled Copy The Database Backups To A Different Location That The Target Server Can Read And Restore From that you can select to break up the process into steps and utilize the (hopefully) elevated permissions of the administrator running the wizard.

When you select this option, the security privileges of the account of the individual running the Data Migration Assistant are used to perform the copy of the file from the backup location to the restore location. The user must have access to each of these locations with the needed read and write permissions for this step to succeed.

The wizard gives the user the option to specify the location to restore the data files and log files on the destination server.

As a final step, the wizard presents the user with a list of logins for migration consideration, with conflicting login names or logins that already exist identified. Where possible, the wizard attempts to map orphaned logins and align login security IDs (SIDs).

Moving to Azure SQL Database The Data Migration Assistant tool performs an Azure SQL Database migration in two phases:

  • Schema. First, it generates a script of the database schema (you can save this script before deployment, for archival and testing purposes), which you deploy to the destination database.

  • Data. If you choose to move the data, another step is added after the creation of the tables on the destination database. This gives you the opportunity to verify that all of the tables exist in the destination database after the initial schema migration. Data migration makes use of Bulk Copy Program (BCP) under the hood.

The schema migration is required; the data migration is optional.

Installing or upgrading SQL Server

When it comes to administration and development tools used to work with SQL Server, the other important tab in Installation Center is the Installation tab. This tab contains a link to install the SQL Server Database Engine/Service. A few of the utilities discussed in this chapter are installed as options only during a full SQL Server Database Engine installation and cannot be downloaded and installed independently.

During an in-place upgrade of an existing SQL Server instance, you can neither add nor remove components. The process will simply upgrade existing components.

If you have multiple versions installed on the same server (instance stacking), a number of shared components will be upgraded automatically, including SQL Server Browser and SQL Server VSS Writer.

Image You can read more about multiple instances and versions of SQL Server on Microsoft Docs at https://docs.microsoft.com/sql/sql-server/install/work-with-multiple-versions-and-instances-of-sql-server.

Tools and services installed with the SQL Server Database Engine

SQL Server 2017 provides a number of optional tools and services that you can select during the installation process. We’ll take a look at some of them in the sections that follow. (Note that this list is not an exhaustive listing and that some of these components might not be available in SQL Server 2017 on Linux.)

Image For more information about configuring different features, see Chapter 4.

Machine Learning Services

SQL Server 2017 builds on the introduction in SQL Server 2016 of R, a statistics language used by data scientists, by introducing Python as a second machine learning (ML) language. As a result, these two languages are now classified as Machine Learning Services.

You can install R and Python independently or together, depending on your requirements. What’s more, you can install these ML services directly in the Database Engine (in-database) or as standalone components.

The in-database option creates a secure integration between the Database Engine and the external runtimes containing the ML libraries. You can run queries using Transact-SQL (T-SQL) and make use of the Database Engine as the compute context.

If you decide to use of R or Python without installing SQL Server, you must choose the standalone option. Each service will then run in its own independent compute context.

Image You can read more about Machine Learning Services on Microsoft Docs at https://docs.microsoft.com/sql/advanced-analytics/r/sql-server-r-services.

Data Quality Services

The standardization, cleaning, and enhancement of data is critical to validity when performing analytical research. SQL Server Data Quality Services allows for both homegrown knowledgebase datasets and cloud-based reference data services by third-party providers.

Data Quality Services is a product that makes possible important data quality tasks, including the following:

  • Knowledgebase-driven correction

  • De-duplication

  • Additional metadata enrichment

Data Quality Services has two parts: the Data Quality Server and the Data Quality Client. Data Quality Server has a dependency on the SQL Server Database Engine. Apart from that, you can install these two components on the same computer or on different computers. The tools are completely independent, and you can install one without having to install the other previously (i.e., the order doesn’t matter).

To be functional, the Data Quality Client tool needs only to be able to connect to a Data Quality Server. There are certain operations the Data Quality Client can perform that require an installation of Microsoft Excel local to the client installation. It is commonplace to have the Data Quality Client on one or more workstations, not the SQL Server instance itself.

Data Quality Server

To install Data Quality Server, you must select its check box during SQL Server 2017 setup, which copies an installer file to your drive. After you have installed SQL Server 2017, to use Data Quality Server you must install it. In your Windows Start Menu, expand Microsoft SQL Server 2017, and then click SQL Server 2017 Data Quality Server Installer. This runs the DQSInstaller.exe file. The installation asks you to type and confirm a database master key password and creates three new databases into the SQL Server instance chosen to be host Server: DQS_Main, DQS_Projects, and DQS_Staging_Data.

Data Quality Client

The Data Quality Client is an application most commonly used in conjunction with master data management, data warehousing, or just plain data cleaning. It is typically used by a data steward who has a deep understanding of the business, and has domain knowledge about the data itself. You can use this tool to create knowledgebases surrounding data element rules, conversions, and mappings to help manage and align data elements. You also can use it to create and rune data quality projects and to perform administrative tasks.

To sign in to a Data Quality Server using the Data Quality Client tool, you must be either a member of the sysadmin server role or one of these three roles in the DQS_Main database:

  • dqs_administrator

  • dqs_kb_editor

  • dqs_kb_operator

Command-line interface

You can use and administer SQL Server from a command line, which is especially relevant with Linux as a supported operating system (OS) for SQL Server. Both the SQLCMD and BCP utilities run on Windows, Linux, and macOS, with some minor differences.

SQLCMD

The SQLCMD is a tool that you can use to run T-SQL statements, stored procedures, or script files, using an ODBC connection to a SQL Server instance.

WHAT DOES ODBC MEAN?

ODBC stands for Open Database Connectivity, which is an open-standard application programming interface (API) for communicating from any supported OS to any supported database engine.

Although some people might consider the tool “old school” because it has been around since SQL Server 2005, it is still very popular because of its versatility. You can invoke SQLCMD from any of the following:

  • Windows, Linux, or macOS command line

  • Windows script files

  • SQL Server Agent job step

  • Using Windows PowerShell with the command line

BCP

If you were thinking that SQLCMD is “old school,” hold on to your hat. BCP makes SQLCMD look like the new kid on the block. BCP was first introduced in 1992 with the release of the very first edition of SQL Server. It’s quite a testament that to this day BCP is still a practical way to work with SQL Server as a means to insert or export large quantities of data. It uses minimal logging techniques and bulk data flows to its advantage.

If you are thinking about SQL Server Integration Services right now, that’s fine, but BCP is not nearly as powerful. You use BCP to move data between data files (text, comma-delimited, or other formats) and a SQL Server table.

You can use it to import files into SQL Server tables or to export data from SQL Server tables into data files. BCP requires the use of a format file to designate the structure of the receiving table and the data types allowed in each column. Fortunately, BCP helps you to create this format file quite easily.

There are a few things about BCP that you must understand and do for the tool to perform optimally (for more information go to https://technet.microsoft.com/library/ms177445.aspx):

  • Use SELECT INTO syntax

  • Put the database into the simple or bulk-logged recovery model

  • Drop any nonclustered indexes on the destination table

  • Insert sorted data and use the sorted_data option if a clustered index exists

  • Run BCP on the same machine as the SQL Server

  • Place source and destination files on separate physical drives

  • Manually grow SQL data files in advance if growth is expected

  • Take advantage of Instant File Initialization

  • Use sp_tableoption to set table lock on bulk load (TABLOCK) to ON

Inside OUT

How do I download the most recent command-line tools?

The versions of SQLCMD and BCP installed with SQL Server 2017 on Windows areupdated through a separate package that is available at https://www.microsoft.com/download/details.aspx?id=53591.

For features like Always Encrypted and Azure Active Directory authentication, a minimum of version 13.1 is required. It is entirely possible (and likely) to have more than one version of SQLCMD installed on a server, so be sure to check that you are using the correct version by running sqlcmd -?.

Separate installers are available for Linux and macOS versions of these command-line tools.

SQL Server PowerShell Provider

If you love to use a command line or if you have begun to use Windows PowerShell to help manage and maintain your SQL Servers, Microsoft offers the PowerShell Provider for SQL Server. Two features are required for you to use this:

  • Windows PowerShell Extensions for Microsoft SQL Server

  • SQL Server Management Objects (SMO)

Both are installed by default with the SQL Server Management Tools, but you also can download and install them separately through the Microsoft SQL Server Feature Pack.

The SQL Server PowerShell Provider uses SQL Server Management Objects. These objects were designed by Microsoft to provide management of SQL Server programmatically. There are many ways that developers and administrators can use Windows PowerShell to automate their work in SQL Server, especially when dealing with multiple server environments.

Image To learn more, see Chapter 13.

SQL Server Configuration Manager

SQL Server Configuration Manager is a tool that uses the Microsoft Management Console as a shell. Because it is not a freestanding program, finding and opening the application can be a little tricky. To launch SQL Server Configuration Manager, on the Windows Start Menu, under Apps, search for SQLServerManager14.msc.

Administrators use SQL Server Configuration Manager to manage SQL Server Services. These services include the SQL Server Database Engine, the SQL Server Agent, SQL Server Integration Services, the PolyBase Engine, and others. SQL Server Configuration Manager provides a GUI to perform the following tasks associated with SQL Server–related services:

  • Start or stop a service

  • Alter the start mode (manual, automatic, disabled)

  • Change startup parameters

  • Create server aliases

  • Change the Log On As accounts

  • Manage client protocols, including TCP/IP default port, keep alive, and interval settings

  • Manage FILESTREAM behavior

Inside OUT

Can I manage SQL Server services from Windows Services Manager?

Although you can perform most of these same tasks using the Windows default services manager (Control Panel > Administrative Tools > Services), in this case we do not recommend using it.

The Windows Services Manager (services.msc) does not provide all of the various configuration options found in the SQL Server Configuration Manager. More important, it can omit adjusting important registry settings that needed to be changed, which will compromise the stability of your SQL Server environment.

You must always change SQL Server services using the SQL Server Configuration Manager. This is especially true for managing SQL Server Service Accounts.

Performance and reliability monitoring tools

The Database Engine Tuning Advisor, Extended Events, and Profiler tools are installed with the SQL Server Database Engine and do not require additional installation steps.

Database Engine Tuning Advisor

Among the many administrative tools Microsoft provides to work with SQL Server is the Database Engine Tuning Advisor. You can start it either from the Start menu or from within SQL Server Management Studio by clicking Tools and then Database Engine Tuning Advisor. Using this tool, you can analyze a server-side trace captured by SQL Server Profiler. It will analyze every statement that passes through the SQL Server and present various options for possible performance improvement.

The suggestions that Database Engine Tuning Advisor makes focus solely on indexing, statistics, and partitioning strategies. The Database Engine Tuning Advisor simplifies the implementation of any administrator-approved changes it suggests. You need to scrutinize these changes to ensure that they will not negatively affect the instance.

Extended events

Technically, the Extended Events GUI (client only) is installed with and is a built-in part of SQL Server Management Studio. An argument could easily be made that it belongs in the section later in the chapter that details tools within SQL Server Management Studio. However, we discuss it here with the other performance-specific tools for categorical reasons.

Image You can read more about how extended events are supported in Azure SQL Database, with some differences, at https://docs.microsoft.com/azure/sql-database/sql-database-xevent-db-diff-from-svr.

SQL Server extended events is an event-handling system created with the intent to replace SQL Server Profiler. Think of it as the “new and improved” version of Profiler. It is more lightweight, full-featured, and flexible, all at once. Extended events offer a way of monitoring what’s happening in SQL Server, with much less overhead than an equivalent trace run through the SQL Profiler. This is because extended events are asynchronous.

You access extended events through SQL Server Management Studio by connecting to a SQL Server instance and navigating to the Management folder. When you’re there, expand the Extended Events node to display Sessions. Right-click this, and then, on the shortcut menu that opens, select the New Session Wizard. You can then use this wizard to schedule events to run at server startup or immediately after the event has been created.

Scripting extended events sessions via T-SQL can be a much quicker and consistent way to create a library of extended event sessions for reuse in multiple environments. This gives you the flexibility to start and stop them as needed, even as a job in SQL Server Agent.

Components

The following subsections describe the extended events components.

Events Because Profiler has been deprecated, a number of new features in SQL Server have matching extended events, but not Profiler events. This means that using extended events to capture diagnostic and performance visibility (rather than Profiler) provides a much larger library of events to choose from than Profiler. Each event has its own set of default fields. In addition, there are global fields (known as actions) that you can add to the collection of any event, for example, database_name, database_id, sql_text, and username.

Targets (Data Storage Options) Targets are basically the consumers, or recipients of events. Targets can log additional event context upon receipt of an event. The target options allow for different ways to view or even save event data. Although users can observe data during collection with extended events (watching the target in action), we do not recommend that you do so on a production machine. Targets come in two flavors:

  • File (event_file target). Best for large datasets, later analysis, remote analysis for retrieval by a consultant or tool, or historical record keeping/baselines. Options with this target setting are where to save the file and what to name it, what the maximum file size should be, should the file roll over and how many files total should be saved.

  • Memory (ring_buffer target). Best for smaller datasets or long sessions. With this option, the user can specify how many events to keep, how much memory to use (max), or how many events (per type) to keep.

Actions These are instructions that specify what to do when an event fires. Actions are associated with events.

Predicates These are filters that limit event firing and provide a more concise view of the issue being reviewed. Some examples are LoginName, ApplicationName, or SPID.

Scenarios for use

You can use extended events for a wide range of scenarios. As of SQL Server 2017, you can choose from more than 1,500 events. Here are some of the most common uses for extended events:

  • Troubleshooting

  • Diagnosing slowness

  • Diagnosing deadlocks

  • Diagnosing recompiles

  • Debugging

  • Login auditing

  • Baselining

By scripting out an event session and using automation, you have a stock set of sessions that you can use to troubleshoot depending on the problem. You can deploy these solutions on any server that needs a closer examination into performance issues.

You can also use extended event trace to provide a baseline from which you can track code improvements or degradation over time.

Management data warehouse

The management data warehouse, introduced in SQL Server 2008, collects data about the performance of a SQL Server instance, and feeds the information back to an administrator in a Visual Analytic style format. Management data warehouse has its own relational database containing tables that are the recipient (target) of specific extended events collection activities.

Upon installation, the data warehouse provides three reports: Server Active History, Query Statistics History, and System Disk Usage. You can create additional reports and add them to the data warehouse collection.

Using the three-report configuration of management data warehouse makes it possible for a database administrator to do basic performance baselining and to plan for growth. It also allows for proactive tuning activities. It might be good practice to set this up when you install a new instance of SQL Server.

Installing a management data warehouse

Perform the following steps to install your management data warehouse:

  1. In SQL Server Management Studio, in Object Explorer, expand the Management node, and then right-click Data Collection. On the shortcut menu that opens, point to Tasks, and then select Configure Management Data Warehouse, as shown in Figure 1-2.

    Image

    Figure 1-2 Navigating to the Management Data Warehouse menu item.

  2. In the Configure Management Data Warehouse Wizard, Select Create Or Upgrade A Management Data Warehouse, and then click Next.

  3. The server name is already populated, so either select the Management Data Warehouse database you are already using for collection by clicking it in the Database Name list box, or, to the right of the list box, click New. If you click New, in the New Database dialog box that opens, type the database name to which you want to store the information collected by the management data warehouse, as demonstrated in Figure 1-3.

    Image

    Figure 1-3 Creating a new database for collecting management data warehouse data.

  4. Select a user to map to the Management Data Warehouse role.

Setting up a data collection

After you install your management data warehouse, you need to set up a data collection to collect data from the server and databases of interest. Here’s how to do that:

  1. In Object Explorer, expand the Management node, right-click Data Collection, point to Tasks, and then click Configure Data Collection.

  2. In the wizard that opens, select the Server Name and Database Name specified during the installation. Finish by choosing any other needed settings.

Go back and view Data Collection node. Things look different now: The Data Collection Sets in Object Explorer as well as the Data Collection node itself no longer displays a red down-arrow icon, as depicted in Figure 1-4.

Image

Figure 1-4 Active data collection sets.

Accessing reports

To access the management data warehouse reports, right-click Data Collection, point to Reports, and then move through the menus to the report that you would like to view, as shown in Figure 1-5.

Image

Figure 1-5 Accessing the management data warehouse reports.

SQL Server Reporting Services

Starting with SQL Server 2017, SQL Server Reporting Services is a separate download outside of the SQL Server installer. You can use SQL Server Reporting Services to create reports against a variety of data sources. It includes a complete set of tools for creating, managing, scheduling, and delivering reports. The reports can include charts, maps, data matrixes, and, with the addition of Microsoft Power BI, R, and Python, almost unlimited data visualizations that are rich and limited only by creativity.

You install SQL Server Reporting Services in Native mode, which provides a web portal interface to manage and organize reports and other items. Internet Information Services (IIS) is not required to use SQL Server Reporting Services, as it was in versions prior to SQL Server 2016.

Installation

You must download SQL Server Reporting Services separately, either by following the stub on the Installation Center screen or by going to https://www.microsoft.com/download/details.aspx?id=55252.

Completing the installation of SQL Server Reporting Services sets up and configures the following services and features:

  • Installs the Report Server Service, which consists of the following:

    • Report Server Web Service

    • Web Portal for viewing and managing reports and report security

    • Report Services Configuraton Manager

  • Configures the Report Service and Web Portal URLs

  • Establishes the Service accounts needed for SQL Server Reporting Services to operate

Image You can read more about configuring SQL Server Reporting Services in Chapter 4.

After the installation is complete, using administrative rights, browse to the following directories to verify that the installation was in fact successful and that the service is running:

If you are running a nondefault instance of SQL Server, you might need to use the Web Portal URL tab in the Report Services Configuration Manager dialog box to determine the exact path of both the Web Service URL and the Web Portal URL, as illustrated in Figure 1-6.

Image

Figure 1-6 Web Portal URL setting in Reporting Services Configuration Manager.

Report Services Configuration Manager

The Report Services Configuration Manager simplifies customization of the behavior of features and capabilities offered by SQL Server Reporting Services. You can use it to perform the following tasks and more:

  • Create or select existing Report Server databases

  • Define the URLs used to access the Report Server and Report Manager

  • Configure the Report Server Service Account

  • Modify the connection string used by the Report Server

  • Set up email distribution capability

  • Integrate with a Power BI service

Inside OUT

Configuring SQL Server Reporting Services: the long and winding road…

The Configuration Manager in SQL Server Reporting Services comes with no shortage of customization options. Beyond the default, you can alter the configuration of almost any setting using the GUI, through SQL Server Management Studio, and also directly via web.config files, and even in some cases the Windows registry. Customizing accounts, IP addresses, ports, or behaviors can be quite an endeavor, the scope of which is far beyond what we can cover in this chapter.

You can find more information at https://docs.microsoft.com/sql/reporting-services/install-windows/reporting-services-configuration-manager-native-mode.

SQL Server Management Studio

SQL Server Management Studio is the de facto standard SQL Server database development and management tool. It provides a rich graphical interface and simplifies the configuration, administration, and development tasks associated with managing SQL Server and Azure SQL Database environments. SQL Server Management Studio also contains a robust script editor and comes stocked with many templates, samples, and script-generating features.

Inside OUT

Does SQL Server Management Studio support other operating systems?

SQL Server Management Studio is a Windows-only application; it does not work in Linux and macOS environments. Instead, you can use the free cross-platform Microsoft SQL Operations Studio to connect to SQL Server, Azure SQL Database and SQL Data Warehouse from Windows, Linux, and macOS.

SQL Operations Studio is an exciting addition to your toolkit.

Releases and versions

Since the release of SQL Server 2016, SQL Server Management Studio is a freestanding toolset that you can download and install independent of the Database Engine.

Initially, Microsoft went with monthly releases, but beginning in August of 2016, the company changed to a versioned release system that allows for more flexibility, and no longer uses a month/year naming convention.

Installing SQL Server Management Studio

To install SQL Server Management Studio, download the latest version of the product by either doing a web search or going to https://docs.microsoft.com/sql/ssms/download-sql-server-management-studio-ssms.

After you download the executable file, install and then watch the Package Progress and Overall Progress meter bars do their thing. There’s not much more to it than that. The installation finishes with a Setup Completed message.

At this point, you can start the application by browsing through your Start Menu to Microsoft SQL Server Tools 17 > Microsoft SQL Server Management Studio 17. For ease of access, you might want to pin the program to your Start Menu or copy the icon to your desktop.

Upgrading SQL Server Management Studio

SQL Server Management Studio will notify you if an update is available. You can also manually check whether one is available. To do so, in SQL Server Management Studio, on the toolbar, select Tools, and then choose Check For Updates. The different versions of the SQL Server Management Studio components—the installed version and the latest available version—will display. If any updates are available, you can click the Update button to bring you to a webpage from which you can download and install the latest recommended version.

Now that the tools used to manage SQL Server are completely independent of the Database Engine, upgrading these components has become very easy. It has also become much safer to upgrade: there is no longer any concern about accidentally affecting your production environment (SQL Server Database Engine) because you upgraded your SQL Server Management Studio toolset.

Features of SQL Server Management Studio

The power of SQL Server Management Studio is in the many ways in which you can interact with one or more SQL Server instances. Listing each one would require its own book, so this section highlights only some useful features.

Object Explorer and Object Explorer Details

Object Explorer is the default SQL Server Management Studio view, providing both a hierarchical and tabular view of each instance of SQL Server and the child objects within those instances (including databases, tables, views, stored procedures, functions, and so on).

Object Explorer presents two panes (see Figure 1-7): the Object Explorer pane (left) and the Object Explorer Details pane (right). The Object Explorer pane is strictly hierarchical, whereas the Object Explorer Details pane is both hierarchical and tabular; as such, it provides additional functionality over its companion pane; for example, object search and multiple, and noncontiguous object selection and scripting. To display the Object Explorer Details pane, click View > Object Explorer Details, or press F7.

Image

Figure 1-7 The Object Explorer view in SQL Server Management Studio.

Server Registration

The Server Registration feature within SQL Server Management Studio can save time and make it easier to manage a complex environment by saving a list of commonly accessed instances. Registering connections in advance for future reuse provides the following benefits:

  • Preservation of connection information

  • Creation of groups of servers

  • Aliasing of servers with more meaningful names

  • Ability to add detailed descriptions to both servers and server groups

  • Import and export of registered server groups for sharing between machines or teammates

To access the Server Registration feature within SQL Server Management Studio, click View > Registered Servers, or press Ctrl+Alt+G. You can use SQL Server Management Studio to manage four different types of servers and services:

  • Database Engine

  • Analysis Services

  • Reporting Services

  • Integration Services

Database Engine When you use the Registered Servers feature to work with Database Engines, two nodes appear: Local Server Groups and Central Management Servers. Each of these has some very useful features:

  • Local Server Groups. The Local Server Groups node allows for the addition of either freestanding individual server registrations or the creation of server groups. Think of server groups as “folders” within the Local Server Groups node. Each of these folders can contain one or more individual servers. Figure 1-8 shows one of the many ways in which you can use the Local Server Groups feature to organize and save frequently used Database Engine connections.

    Image

    Figure 1-8 The Local Server Group.

  • Exporting Registered Servers. To access the Export Registered Servers Wizard, right-click the Local Server Groups folder node or any folder or server nested within this node. On the shortcut menu, point to Tasks, and then click Export. From there, you have quite a bit of freedom; you can choose to export from any level within the tree structure and whether to include user names and passwords. In the preceding case, if you wanted to export only the Development Servers node and those servers within it, you could do so easily. Using the wizard, you can choose where to save the created file and then build out an XML document with the extension .regsrvr.

  • Importing Registered Servers. To access the Import Registered Servers Wizard, right-click the Local Server Groups folder node or any folder or server nested within this node. On the shortcut menu, point to Tasks, and then click Import. Browse to and select a previously created .regsrvr file, as demonstrated in Figure 1-9.

    Image

    Figure 1-9 Importing registered servers.

    From here you can choose in which folder you would like the imported object or object tree to reside. If you select a folder that already contains the same structures you are attempting to import, a message will appear asking you to approve or disapprove an update/overwrite to the existing object structure.

  • Central Management Servers. The second node available in the Database Engine feature is Central Management Servers. At first glance, this might appear to be almost the same thing as Local Server Groups: you’re able to add servers and create folders with descriptive names to which you can add servers. And, yes, in this way, it is much the same. However, Centralized Management Servers includes some very significant differences.

    First, when using this feature, you must choose a SQL Server Database Engine to play the role of a Central Management Server (CMS). You can alias the server with a new name, but the server itself must exist. After you have chosen a server to play this role and have created a CMS, you can create new Server Groups or individual Server Registrations using the same methods explained in the Local Server Groups section.

Here is where things become interesting! If you right-click any level (a server, a group, or the CMS itself), you are presented with multiple options:

  • New Query

  • Object Explorer

  • Evaluate Policies

  • Import Policies

Anything that is run will be run against each of the servers in the chosen group’s tree. Running a query against the CMS itself will result in the query being run against every server hierarchically present in all trees within the CMS. This is a very handy feature, but with great power comes great responsibility!

The default behavior of CMS is that multiple server results are merged into one result set. You can change and customize this behavior by going to Tools > Options > Query Results > SQL Server > Multiserver Results, and then turning on the Merge Results setting. Other behavior options available here include Add Login Name and Add Server Name to the result set from a CMS query.

When you create a CMS on an existing SQL Server, others can access and utilize the structure setup, so there is no need to Export or Import and keep folders and structures synchronized. This is great for team collaboration and efficiency.

Filtering objects

In the default Object Explorer view, SQL Server Management Studio lists objects within each category in alphabetical order. There are several main groups, or tree categories, that are common across all versions of SQL Server. These include the following:

  • Databases. The full list of databases (including system databases) on the SQL Server instance. Database snapshots also appear here.

  • Security. A diverse list of object types here, including Logins, Server Roles, Credentials, Cryptographic Providers, and Audits.

  • Server Objects. These include Backup Devices, Endpoints, Linked Servers, and Triggers (server-level triggers).

  • Replication. Information about Publishers and Subscriptions.

  • Always On High Availability. Includes Failover Clustering and Availability Groups.

  • Management. Covers a number of diverse features and tools, including Policy Management, Data Collection, Resource Governor, Extended Events, Maintenance Plans, Database Mail, DTC (Distributed Transaction Coordinator), and SQL Server error logs.

  • SQL Server Agent. Covers jobs, alerts, operators, proxies, and error logs of its own.

  • Integration Services Catalogs. SQL Server Integration Services package catalog. Depends on SQL Server version.

By default, SQL Server Management Studio lists all objects alphabetically beneath each tree category. When working with databases that have a large quantity of objects, this can become quite aggravating as the user waits through potentially long list load times and expends energy scrolling and watching the screen very closely for the object in question.

Fortunately, SQL Server Management Studio has a filtering feature! You can apply filters to many object categories; for example, user databases, tables, views, stored procedures, table-valued functions, user-defined functions, and even database users.

You can configure filter settings in either the Object Explorer pane or the Objects Explorer Details pane independently. Table 1-2 lists the available filtering options.

Table 1-2 SQL Server Management Studio Filters and Options

Filter

Options

Name

Contains

Equals

Does Not Contain

Schema

Contains

Equals

Does Not Contain

Owner

Equals

Does Not Equal

Is Natively Compiled

True

False

Creation Date

Equals

Less Than

Less Than or Equal

More Than

More Than or Equal

Between

Not Between

After you have selected a filter, the suffix “(filtered)” appears in the Object Explorer or Object Explorer Details tree, above your filtered list.

To clear an applied filter and display all objects in a tree again, right-click a filtered category, select Filter, and then click Remove Filter.

Multi-Select In the Object Explorer pane, you can select only one object at a time. The Object Explorer Details pane, however, provides a Multi-Select feature with which you can work on multiple objects at the same time (tables, views, jobs, and so on). Following the standard in the Windows environment, the Shift key allows for the selection of contiguous objects, whereas the Ctrl key allows for noncontiguous selecting. You can specify actions against multiple objects using the GUI or choose to script multiple objects at once. Scripting each object into its own file or merging all object scripting into one larger file are both available options.

Additional tools in SQL Server Management Studio

SQL Server Management Studio provides a number of time-saving tools and techniques for making you more productive. The following subsections provide just a few highlights.

IntelliSense tools

IntelliSense is a ubiquitous Microsoft technology found in many of its products that helps you with code completion. IntelliSense effectively reduces the amount of typing you do by offering shortcuts and autocompletion of keywords and object names, which also makes your code more accurate.

Additionally, SQL Server Management Studio comes with snippets to help you code more easily. Snippets are preconfigured code fragments that you can quickly drop into or around an existing block of code. The two options for using them are Insert Snippet and Surround With Snippets. You also can create your own snippets (you build them using XML), but that is beyond the scope of this discussion.

Let’s take a look at some use cases for snippets.

One of the options for SQL Server 2012 and later includes a snippet for an IF statement. After testing a block of code, you can quickly add the IF statement (including the BEGIN/END statements) by highlighting your code and choosing a snippet.

There are three ways to access snippets

  • Use a keyboard shortcut

  • Right-click and use the option from the context menu that opens

  • On the Edit menu, point to IntelliSense, and then click the snippets option you want—Surround With, in the example shown in Figure 1-10.

Image

Figure 1-10 Accessing the Surround With snippet from the Edit menu.

You can double-click the Function folder to see the available snippets; clicking a snippet surrounds the highlighted code with the snippet template code. You also can insert “placeholder” text that you can replace later.

There are only a few stock Surround With snippets, but many Insert Snippets. You can find these by going to the Edit menu, pointing to IntelliSense, and then clicking Insert Snippet. You use them in the same manner you do for Surround With snippets, except that the code is placed at the current location of the cursor within a block of code. There are also keyboard shortcuts to use this feature. You can use Ctrl+K, Ctrl+S for Surround With snippets, and Ctrl+K, Ctrl+X for Insert Snippets.

Inside OUT

Did someone say keyboard shortcuts?

SQL Server Management Studio offers a large range of keyboard shortcuts for increasing productivity.

For example, you can show and hide the results pane of a query by using Ctrl+R. Accessing the Code Snippets Manager is as easy as using the combination Ctrl+K, Ctrl+B. Do you want to include the Actual Query Plan in a query? Use Ctrl+M. Ctrl+F5 parses a query before you run it to ensure that the syntax is correct. By far the most popular one is F5, which runs a query, but you can also use Ctrl+E to do that.

Customizing menus and shortcuts

SQL Server Management Studio is based on the Visual Studio integrated development environment (IDE), which means that it is customizable and extensible. Adding extensions is beyond the scope of this book, but the next few sections describe how to customize elements such as the toolbars and keyboard shortcuts.

Customize toolbars SQL Server Management Studio installs with only the standard toolbar as the default. There are many other toolbars available for use. To access these options, on the toolbar, click Tools, and then click Customize. In the Customize dialog box, there are two tabs. on the first tab, Toolbars, you can select the toolbars that are useful in your work environment. Among the many choices are toolbars for working with Database Diagrams, extended events, XML, and even a web browser. On the second tab, the Commands tab, you can set up a custom toolbar or edit the drop-down menus and functionality of the existing toolbars.

Tool options You also can customize the appearance of your SQL Server Management Studio interface. Click Tools and then Options to adjust color, font, keyboard hotkeys, length of strings in results, location of results, scripting preferences, international settings, theme, autorecovery timeframe, and more.

One very handy option is the Keyboard, Query Shortcuts feature. SQL Server Management Studio comes with several shortcuts already turned on (see Figure 1-11), but you can tailor these to your needs. Many long-time DBAs make heavy use of this feature to reduce the number of keystrokes to carry out common stored procedures.

Using shortcuts in SQL Server Management Studio, you can highlight text and then press the shortcut to run the associated stored procedure, supplying a parameter of the highlighted text. For instance, to see the text of a stored procedure or view, you can use the system procedure sp_helptext. By adding this stored procedure to the shortcut Ctrl+0 (which you can see in Figure 1-11), displaying the data definition language (DDL) of any scripted object within a database requires nothing more than a highlight of a name and simple key combination.

Image

Figure 1-11 Managing query shortcuts.

Error logs

Each SQL Server instance maintains a distinct set of relevant error log messages that are accessible in two places: in the Management/Error Logs node, and in a context menu when you right-click an instance in the Registered Servers window. By default, these log files contain information about the SQL Server instance when coming online, what configuration settings were applied (or failed to apply), when backups occurred, when corruption is detected, when I/O is taking too long, partial stack dumps, and lots of other useful pieces of information. It’s a great place to go to when troubleshooting stability or performance problems and to look for things that might cause trouble in the future.

To keep the log information to a reasonable and searchable size, the information is kept in a series of files rather than a single file. It is possible to close one file and start a new, blank file. Unfortunately, the default settings for cycling the log are not very useful.

By default, SQL Server keeps the six most-recent error log files. To configure the number of log files to maintain, in the SQL Server Management Studio Object Explorer, in the Management folder, right-click SQL Server Logs, and then select Configure. In the dialog box that opens, select the check box labeled Limit The Number Of Error Log Files Before They Are Recycled, and then, in the Maximum Number Of Error Log Files box, type a value. The value must be between 6 and 99.

Image For more about this and other post-installation checklist items, see Chapter 4.

Every time the SQL Server service is restarted, it cycles the log file. This creates a brand new, empty log file and moves the previous log file down one spot in the list. Any log file older in sequence than the maximum specified number of files to keep is deleted.

You also can choose to manually cycle the log file by using the sp_cycle_errorlog command, or you can automate this process by using a SQL Server Agent job to perform this task. When working with SQL Server instances that are quite large and remain online for a long timeframe, this can prevent any single log file from becoming overly large and unwieldy.

No matter which method you use, the resulting action is the same: the current file is closed and a new, blank file is opened. If this causes the file count to exceed the maximum number of files, the oldest file is deleted.

Activity Monitor

Activity Monitor is a tool that provides information about what is currently running on the SQL Server and how that code might be affecting the instance. It provides the ability to easily view common hardware-specific performance metrics and a list of recently used queries (with metrics, code, and execution plans). You can sort all of the grids, and you can filter some of them. Out of the box, this is the place to begin if you need to do rudimentary troubleshooting and baselining.

To open the Activity Monitor window, In the Object Explorer pane, right-click the SQL Server instance, and then select Activity Monitor. The window opens in the Object Explorer Details pane.

Activity Monitor consists of six distinct parts:

  • Overview. Displays a basic version of what you might already be familiar with viewing in the Task Manager window but with a SQL Server flair, with four distinct graphs

  • Processes. Displays all nonsystem processes with open connections to the SQL Server instance

  • Resource Waits. Displays the Wait Events of active, open connections

  • Data File I/O. Displays a difference between two interval readings of the storage subsystem

  • Recent Expensive Queries. Displays information about the most expensive queries from the past 30 seconds

  • Active Expensive Queries. Displays a more detailed view of queries that are running at that moment

You can expand each of these six parts to show more information, with the Overview section expanded by default. If you want to sort or filter the results, click the column header of any of the columns in each section.

Activity Monitor overview

Four graphs cover the most basic overview of the instance. The % Processor Time is an average combined value for all logical processors assigned to the instance (see the section “Carving up CPU cores using an affinity mask” in Chapter 3). The other three graphs are Waiting Tasks (an instance-level value), Database I/O (all databases, measured in MB/sec) and Batch Requests/sec (all databases).

Each of the graphs display information in real time; however, you can configure the refresh interval by right-clicking any of the graphs. The default for each is 10 seconds; you can adjust this from as short as one second to as long as one hour. The graph settings are adjusted as a unified set, meaning that all four graphs use the same interval setting, so changing one interval changes them all. Likewise, selecting Pause on any of the graphs pauses the entire set.

Processes

The Processes section of Activity Monitor displays all nonsystem processes (also known as tasks) with open connections to the SQL Server instance, regardless of whether the process is actively running a query. Important metadata provided includes the following:

  • Session ID. The session process identifier (SPID) of the current process

  • User Process. Displays a 1 if this is a user process; 0 if it is a system process

  • Login. The login name for the user running this process

  • Database. The name of the database

  • Task State. Populated from the list of possible tasks in the task_state column of the sys.dm_os_tasks dynamic management view

  • Command. Populated from the list of command types in the command column of the sys.dm_exec_requests dynamic management view

  • Application. The name of the application

  • Wait Time (ms). Amount of time that this task has been waiting, in milliseconds

  • Wait Type. The current wait type for this task

  • Wait Resource. The resource for which this task is waiting

  • Blocked By. If this task is being blocked by another process, this shows the SPID of the blocking process

  • Head Blocker. If there is a chain of blocking processes, this is the SPID of the process at the start of the blocking chain

  • Memory Use (KB). How much memory this process is using

  • Host Name. The host name of the machine that made this connection

  • Workload Group. The name of the Resource Governor workload group that this process belongs to (you can read more about the Resource Governor in Chapter 3)

To see the detailed T-SQL query being run (last T-SQL command batch), to trace the process in SQL Profiler, or to Kill the process, right-click any of the rows in the Processes pane.

Resource Waits

The Resource Waits section of the Activity Monitor tool displays the Wait Events of active, open connections, sorted by default by the Cumulative Wait Time in seconds. This can be very useful when you’re trying to determine the root cause of a performance issue. Having a baseline for these counters when “things are good” is very useful later on when you’re trying to gauge whether a problem being experienced is “new” or “normal.” Understanding the meaning of certain wait times can help you to diagnose the root cause of slowness, be it drive, memory pressure, CPU, network latency, or a client struggling to receive and display a result set. Following are the wait statistics provided by this section:

  • Wait Category

  • Wait Time (ms/sec)

  • Recent Wait Time (ms/sec)

  • Average Waiter Count

  • Cumulative Wait Time (sec)

Image You can read more about Resource Waits at https://technet.microsoft.com/library/cc879320.aspx.

Data File I/O

The Data File I/O section of Activity Monitor displays the difference between two readings taken from the metadata stored in the sys.dm_io_virtual_file_stats dynamic management view. For this reason, when you first expand the section, you might not see results for a short while. The server needs to have at least two readings (so if your interval is 10 seconds, you’ll wait 10 seconds before data appears). The information displayed shows each of the data files for all of the databases on the SQL Server, the file location and name, the megabytes per second read (MB/sec read), megabytes per second written (MB/sec written), and average response time in milliseconds (ms).

As a general rule, average response times of five milliseconds or less allow for acceptable performance, notwithstanding the occasional outlying peak.

Recent Expensive Queries

Activity Monitor’s Recent Expensive Queries section displays information about the most expensive queries that have run on the SQL Server instance in the past 30 seconds. It includes both queries in flight and queries that finished. To see the full query text or to see the execution plan currently being used, right-click any of the queries listed. Here are the fields returned in this pane:

  • Query

  • Executions/Min

  • CPU (ms/sec)

  • Physical Reads/sec

  • Logical Writes/sec

  • Logical Reads/sec

  • Average Duration (ms)

  • Plan Count

  • Database

Active Expensive Queries

If you’re trying to determine what is running at this precise moment that might be causing performance issues, Active Expensive Queries is the place to look. This section of Activity Monitor is more granular than the aggregated “past 30 seconds” view provided in the Recent Expensive Queries section. In addition, the list of queries here shows some very interesting details that are available at only a granular level:

  • Session ID

  • Database

  • Elapsed Time

  • Row Count

  • Memory Allocated

Again, you can see the full query text and the execution plan by right-clicking, but here you get an additional feature, Show Live Execution Plan, which might very well differ if a query is running long.

Inside OUT

Does Activity Monitor use resources?

In a nutshell, yes, it does. When you expand any of the detail areas in Activity Monitor, it must query the system metadata in real time to keep the columns and/or graphs populated on the screen. When you collapse the area, these queries stop.

Thus, after you have finished viewing a section, we recommend that you collapse that section, or close the Activity Monitor tab, to avoid any unnecessary “observer overhead.”

SQL Server Agent

SQL Server Agent is a service on both Windows and Linux that you can use to schedule automated tasks, called Jobs, as illustrated in Figure 1-12. These Jobs are most commonly used to run routine maintenance (backups, index defragmentation, statistics updates, and integrity checks), but you can also use them to periodically run custom code.

There is built-in functionality for Job Notifications that makes it possible for a person or group to receive communications about the status of a job, using the Database Mail feature. The setup provides a few straightforward configuration options as to when notifications are sent: Success, Failure, and Completion.

Image For more information on configuring Database Mail and configuring SQL Agent to use Database Mail, see Chapter 13.

SQL Server Agent’s list of Jobs also includes any SQL Server Reporting Services subscriptions that have been created and scheduled on the server.

Image

Figure 1-12 The SQL Server Agent tree view.

Job Activity Monitor

Job Activity Monitor gives a snapshot view of all jobs on a server. Using this feature, you can quickly see many attributes about the Jobs scheduled on a SQL Server instance. You can use many of these attributes to narrow the list of jobs being viewed. This can be especially handy if there are many hundreds of SQL Server Reporting Services reports scheduled, or the list of jobs is extensive. Table 1-3 lists the attributes.

Table 1-3 Job activity attributes

Job activity attribute

Values

Can use to filter?

Name

 

Enabled

No

Yes

Status

Between Retries

Executing

Idle

Not Idle

Performing Completed Action

Suspended

Waiting for Step to Finish

Waiting for Worker Thread

Last Run Outcome

Canceled

Failed

In Progress

Retry

Succeeded

Unknown

Last Run Date Time

 

Next Scheduled Run Date Time

 

Job Category

 

Is The Job Runnable?

Yes

No

Is The Job Scheduled?

Yes

No

Job Category ID

 

 

Notifying operators with alerts

You can configure alerts to notify you when a specific event occurs. Unlike jobs that run on a schedule, alert notifications can be sent as a reaction to a scenario that has been set off. Examples include emailing the DBA team when a data or log file experiences auto growth, or when Target Server Memory drops below a certain threshold on a virtual machine. SQL Server Agent’s alerting feature gives an administrator the ability to create alerts of three different types:

  • Event alerts. Raised by SQL Server’s Error and Severity mechanism. You can specify this for all databases or for a single database. You can use Error Number or Severity Level to set off an alert. Text within the System Message can be parsed to only alert in specific scenarios.

  • Performance condition alerts. These utilize the entire library of SQL Server Performance Monitor counters. Any Counter Object can be chosen, the Sub Counter Object specified, the Counter Instance (if applicable), and a threshold (falls below, becomes equal to, rises above) at which an alert should fire. Figure 1-13 depicts setting up a Performance Condition Alert Definition to notify an administrator if Page Life Expectancy on an instance of SQL has dropped below five minutes.

    Image

    Figure 1-13 Creating a performance condition alert.

  • Windows Management Instrumentation (WMI) alerts. A WMI alert uses the Windows Management Instrumentation Event Provider to allow for more complicated actions upon event detection setting off an alert. One example is to use the alerting system to detect a deadlock and then save the XML deadlock graph information to a table for later analysis. Another use is to detect any DDL or system configuration changes that occur and to document them for review at a later time. Because the WMI Provider has access to many Server Event Classes and Properties, this feature is quite versatile. It does come with a couple of catches, however:

    • It requires that Service Broker is turned on in the msdb database of the instance.

    • If your code queries objects within a particular database on the server, Service Broker must be enabled on that database also.

    • It is not very GUI friendly and requires a bit more programming know-how than the other alert options.

Image You can read more about creating WMI alerts in Chapter 13 as well as at https://docs.microsoft.com/sql/ssms/agent/create-a-wmi-event-alert.

A response to an alert can be to run a job, notify a list of operators, or both.

Operators

Operators are users or groups designated as points of contact to receive notifications from the SQL Server Agent. They are defined most commonly with email addresses, but there are additional delivery methods available.

Inside OUT

Azure SQL Database lacks SQL Server Agent

If you use SQL Server Management Studio to connect to an Azure SQL Database, you might notice the absence of SQL Server Agent.

Although at first this might seem puzzling, it makes perfect sense. SQL Server Agent is an OS service. Azure SQL Database is a database as a service (DBaaS), which is essentially a sole database (à la carte) minus the server and OS pieces of the platform.

The Azure environment comes with its own Azure Automation services, which you can use to schedule routines similar to what DBAs are used to with SQL Server Agent. But remember, with Azure SQL databases, point-in-time recovery is included automatically.

Another option is to use a Managed Instance, which is covered in Chapter 5.

SQL Server Data Tools

Similar to SQL Server Management Studio, SQL Server Data Tools is a free-standing installation of tools meant to be used with SQL Server. The SQL Server Data Tools installation provides a developer with tools for working with SQL Server Integration, Reporting, and Data Warehousing. The tools provided in SQL Server Data Tools run within a Visual Studio shell, without requiring the Visual Studio product outright. This shell is installed by using SQL Server Data Tools.

SQL Server Integration Services

SQL Server Integration Services is a versatile platform for importing, transforming, and exporting data. Frequently used for Extract, Transform, and Load (ETL) processes, SQL Server Integration Services can integrate with many external systems using standard tasks, interfaces and protocols.

SQL Server Integration Services manages these solutions using packages, which you create and modify via a graphical user interface.

SSISDB Upgrade Wizard

The SQL Server Integration Services Package Upgrade Wizard is a tool that you can use to upgrade SQL Server Integration Services packages that were created in versions earlier than SQL Server 2017. Although you most commonly access this tool from SQL Server Data Tools, you can also find and launch it from SQL Server Management Studio and also from the Windows command prompt. Part of the upgrade wizard in all of these scenarios involves the automated backup of the original packages.

From SQL Server Data Tools:

  1. Open an Integration Services Project

  2. Right-click SSIS Packages

  3. Select Upgrade

From SQL Server Management Studio:

  1. Connect to Integration Services

  2. Expand Stored Packages

  3. Right-click MSDB (File System)

  4. Select Upgrade

From the Windows command prompt:

  1. Navigate to the Microsoft SQL Server140DTSBinn Folder

  2. Locate and run the SSISUpgrade.exe file

The Import And Export Data Wizard

The SQL Server Import And Export Wizard is a tool that simplifies the copying of data from a source to a destination. It uses SQL Server Integration Services to copy data by creating a package in memory. You can choose to save the package the wizard creates for future reuse. The quantity of various sources and destination platforms that you can use can use with the wizard is generous. In some cases, you might need to download and install additional drivers and providers from a vendor or from a Microsoft Feature Pack. Table 1-4 lists examples of compatible data sources.

Table 1-4 Data sources in the Import And Export Wizard

Type

Details

Enterprise databases

SQL Server, Oracle, DB2

Text files

 

Excel/Access

May require Access Runtime

Azure

Azure Blob Storage

Open source

PostgreSQL, MySQL

Others

ODBC, .Net Framework, OLEDB

Data Profiling Task and Viewer

You can use the Data Profiling Task within SQL Server Integration Services to clarify data patterns (normal versus abnormal) and identify data quality issues before they make their way to a destination (usually a data warehouse). The tool provides visibility around the data quality by calculating and documenting the metadata and statistical metrics shown in Table 1-5.

Table 1-5 Data profiling categories and details

Category

Details

Candidate keys

Key columns

Key strength

Column length distribution

Minimum column length

Maximum column length

Detailed count by length

Percentage distribution by length

Column null ratio

Null count by column

Null percentage by column

Column statistics (numeric and date based column data types only)

Minimum value by column

Maximum value by column

Mean value by column

Standard deviation by column

Column value distribution

Number of distinct values by column

Most frequent values by column

The Data Profiling Task creates an XML output file. You can view this file by using the Data Profile Viewer, which is a standalone application and does not require Visual Studio or SQL Server Integration Services to run.

Figure 1-14 presents an example of the Data Profile Viewer displaying the XML created by a Data Profile Tasks, pointed at Microsoft’s WideWorldImporters sample database and analyzing the Sales.Customers table.

Image

Figure 1-14 The Data Profile Viewer showing column distribution.

A note on deprecation

SQL Server 2017 introduces some exciting new features, but some features from earlier versions of SQL Server are deprecated and even discontinued. Deprecated features will be removed from a future version of the product, and you should not use them for new development. Discontinued features have already been removed, and might block upgrades to the latest database compatibility level, or migrations to Azure SQL Database.

Reference is made in several chapters of this book about features that have been deprecated, but the easiest way to stay up to date is to check the Microsoft documentation at https://docs.microsoft.com/sql/database-engine/deprecated-database-engine-features-in-sql-server-2017.

You can also access the list of deprecated features by using the T-SQL query that follows, which provides a list of more than 250 features that are deprecated, along with a count of the number of occurrences on your SQL Server instance. We leave as an exercise for you to identify and resolve specific occurrences.

SELECT object_name, counter_name, instance_name, cntr_value, cntr_type
FROM sys.dm_os_performance_counters
WHERE object_name = ‘SQLServer:Deprecated Features’;

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.11.227