Mastering SQL Server 2017 - Miloš Radivojević - E-Book

Mastering SQL Server 2017 E-Book

Miloš Radivojević

0,0
43,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Leverage the power of SQL Server 2017 Integration Services to build data integration solutions with ease

Key Features

  • Work with temporal tables to access information stored in a table at any time
  • Get familiar with the latest features in SQL Server 2017 Integration Services
  • Program and extend your packages to enhance their functionality

Book Description

Microsoft SQL Server 2017 uses the power of R and Python for machine learning and containerization-based deployment on Windows and Linux. By learning how to use the features of SQL Server 2017 effectively, you can build scalable apps and easily perform data integration and transformation.

You’ll start by brushing up on the features of SQL Server 2017. This Learning Path will then demonstrate how you can use Query Store, columnstore indexes, and In-Memory OLTP in your apps. You'll also learn to integrate Python code in SQL Server and graph database implementations for development and testing. Next, you'll get up to speed with designing and building SQL Server Integration Services (SSIS) data warehouse packages using SQL server data tools. Toward the concluding chapters, you’ll discover how to develop SSIS packages designed to maintain a data warehouse using the data flow and other control flow tasks.

By the end of this Learning Path, you'll be equipped with the skills you need to design efficient, high-performance database applications with confidence.

This Learning Path includes content from the following Packt books:

  • SQL Server 2017 Developer's Guide by Miloš Radivojević, Dejan Sarka, et. al
  • SQL Server 2017 Integration Services Cookbook by Christian Cote, Dejan Sarka, et. al

What you will learn

  • Use columnstore indexes to make storage and performance improvements
  • Extend database design solutions using temporal tables
  • Exchange JSON data between applications and SQL Server
  • Migrate historical data to Microsoft Azure by using Stretch Database
  • Design the architecture of a modern Extract, Transform, and Load (ETL) solution
  • Implement ETL solutions using Integration Services for both on-premise and Azure data

Who this book is for

This Learning Path is for database developers and solution architects looking to develop ETL solutions with SSIS, and explore the new features in SSIS 2017. Advanced analysis practitioners, business intelligence developers, and database consultants dealing with performance tuning will also find this book useful. Basic understanding of database concepts and T-SQL is required to get the best out of this Learning Path.

Miloš Radivojević is a data platform MVP and specializes in SQL Server for application developers and performance/ query tuning. Miloš is a co-founder of PASS Austria. Dejan Sarka, MCT and Microsoft Data Platform MVP, is an independent trainer and consultant who focuses on the development of database and business intelligence applications. He is the founder of the Slovenian SQL Server and .NET Users Group. William Durkin is a data platform architect for Data Masterminds, he is a regular speaker at conferences around the globe, a Data Platform MVP, and the founder of the popular SQLGrillen event. Christian Coté is an MS-certified technical specialist in business intelligence (MCTS-BI). His ETL projects have used various ETL tools and plain code with various RDBMSes (such as Oracle and SQL Server). Matija Lah has more than 15 years of experience working with Microsoft SQL Server, mostly from architecting data-centric solutions in the legal domain.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 568

Veröffentlichungsjahr: 2019

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Mastering SQL Server 2017

 

 

 

 

 

 

 

Build smart and efficient database applications for your organization with SQL Server 2017

 

 

 

 

 

 

 

 

Miloš RadivojevićDejan Sarka
William Durkin
Christian Coté
Matija Lah

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Mastering SQL Server 2017

 

Copyright © 2019 Packt Publishing

 

 

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

 

First Published: August 2019

 

Production Reference: 1140819

 

Published by Packt Publishing Ltd. Livery Place, 35 Livery Street Birmingham, B3 2PB, U.K.

ISBN 978-1-83898-320-8

www.packtpub.com

Contributors

About the Authors

Miloš Radivojević is a database consultant in Vienna, Austria. He is a data platform MVP and specializes in SQL Server for application developers and performance/ query tuning. Currently, he works as a principal database consultant in Bwin (GVC Holdings)—the largest regulated online gaming company in the world. Miloš is a co-founder of PASS Austria. He is also a speaker at international conferences and speaks regularly at SQL Saturday events and PASS Austria meetings.Dejan Sarka, MCT and Microsoft Data Platform MVP, is an independent trainer and consultant who focuses on the development of database and business intelligence applications. Besides projects, he spends about half his time on training and mentoring. He is the founder of the Slovenian SQL Server and .NET Users Group. He is the main author or co-author of many books about databases and SQL Server. The last three books before this one were published by Packt, and their titles were SQL Server 2016 Developer's Guide, SQL Server 2017 Integration Services Cookbook, and SQL Server 2016 Developer's Guide. Dejan Sarka has also developed many courses and seminars for Microsoft, SolidQ, and Pluralsight.William Durkin is a data platform architect for Data Masterminds. He uses his decade of experience with SQL Server to help multinational corporations achieve their data management goals. Born in the UK and now based in Germany, William is a regular speaker at conferences around the globe, a Data Platform MVP, and the founder of the popular SQLGrillen event.

Christian Coté has been in IT for more than 12 years. He is an MS-certified technical specialist in business intelligence (MCTS-BI). For about 10 years, he has been a consultant in ETL/BI projects. His ETL projects have used various ETL tools and plain code with various RDBMSes (such as Oracle and SQL Server). He is currently working on his sixth SSIS implementation in 4 years.Matija Lah has more than 15 years of experience working with Microsoft SQL Server, mostly from architecting data-centric solutions in the legal domain. His contributions to the SQL Server community have led to the Microsoft Most Valuable Professional award in 2007 (data platform). He spends most of his time on projects involving advanced information management, and natural language processing, but often finds time to speak at events related to Microsoft SQL Server where he loves to share his experience with the SQL Server platform.

Packt Is Searching for Authors Like You

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

 
mapt.io

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry-leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why Subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

Packt.com

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. 

Table of Contents

Title Page

Copyright

Mastering SQL Server 2017

Contributors

About the Authors

Packt Is Searching for Authors Like You

About Packt

Why Subscribe?

Packt.com

Preface

Who This Book Is For

What This Book Covers

To Get the Most out of This Book

Download the Example Code Files

Download the color images

Conventions Used

Get in Touch

Reviews

Introduction to SQL Server 2017

Security

Row-Level Security

Dynamic data masking

Always Encrypted

Engine features

Query Store

Live query statistics

Stretch Database

Database scoped configuration

Temporal Tables

Columnstore indexes

Containers and SQL Server on Linux 

Programming

Transact-SQL enhancements

JSON

In-Memory OLTP

SQL Server Tools

Business intelligence

R in SQL server

Release cycles

Summary

SQL Server Tools

Installing and updating SQL Server Tools

New SSMS features and enhancements

Autosave open tabs

Searchable options

Enhanced scroll bar

Execution plan comparison

Live query statistics

Importing flat file Wizard

Vulnerability assessment

SQL Server Data Tools

Tools for developing R and Python code

RStudio IDE

R Tools for Visual Studio 2015

Setting up Visual Studio 2017 for data science applications

Summary

JSON Support in SQL Server

Why JSON?

What is JSON?

Why is it popular?

JSON versus XML

JSON objects

JSON object

JSON array

Primitive JSON data types

JSON in SQL Server prior to SQL Server 2016

JSON4SQL

JSON.SQL

Transact-SQL-based solution

Retrieving SQL Server data in JSON format

FOR JSON AUTO

FOR JSON PATH

FOR JSON additional options

Add a root node to JSON output

Include NULL values in the JSON output

Formatting a JSON output as a single object

Converting data types

Escaping characters

Converting JSON data in a tabular format

OPENJSON with the default schema

Processing data from a comma-separated list of values

Returning the difference between two table rows

OPENJSON with an explicit schema

Import the JSON data from a file

JSON storage in SQL Server 2017

Validating JSON data

Extracting values from a JSON text

JSON_VALUE

JSON_QUERY

Modifying JSON data

Adding a new JSON property

Updating the value for a JSON property

Removing a JSON property

Multiple changes

Performance considerations

Indexes on computed columns

Full-text indexes

Summary

Stretch Database

Stretch DB architecture

Is this for you?

Using Data Migration Assistant

Limitations of using Stretch Database

Limitations that prevent you from enabling the Stretch DB features for a table

Table limitations

Column limitations

Limitations for Stretch-enabled tables

Use cases for Stretch Database

Archiving of historical data

Archiving of logging tables

Testing Azure SQL database

Enabling Stretch Database

Enabling Stretch Database at the database level

Enabling Stretch Database by using wizard

Enabling Stretch Database by using Transact-SQL

Enabling Stretch Database for a table

Enabling Stretch DB for a table by using wizard

Enabling Stretch Database for a table by using Transact-SQL

Filter predicate with sliding window

Querying stretch databases

Querying and updating remote data

SQL Server Stretch Database pricing

Stretch DB management and troubleshooting

Monitoring Stretch Databases

Pause and resume data migration

Disabling Stretch Database

Disable Stretch Database for tables by using SSMS

Disabling Stretch Database for tables using Transact-SQL

Disabling Stretch Database for a database

Backing up and restoring Stretch-enabled databases

Summary

Temporal Tables

What is temporal data?

Types of temporal tables

Allen's interval algebra

Temporal constraints

Temporal data in SQL Server before 2016

Optimizing temporal queries

Temporal features in SQL:2011

System-versioned temporal tables in SQL Server 2017

How temporal tables work in SQL Server 2017

Creating temporal tables

Period columns as hidden attributes

Converting non-temporal tables to temporal tables

Migrating an existing temporal solution to system-versioned tables

Altering temporal tables

Dropping temporal tables

Data manipulation in temporal tables

Inserting data in temporal tables

Updating data in temporal tables

Deleting data in temporal tables

Querying temporal data in SQL Server 2017

Retrieving temporal data at a specific point in time

Retrieving temporal data from a specific period

Retrieving all temporal data

Performance and storage considerations with temporal tables

History retention policy in SQL Server 2017

Configuring the retention policy at the database level

Configuring the retention policy at the table level

Custom history data retention

History table implementation

History table overhead

Temporal tables with memory-optimized tables

What is missing in SQL Server 2017?

SQL Server 2016 and 2017 temporal tables and data warehouses

Summary

Columnstore Indexes

Analytical queries in SQL Server

Joins and indexes

Benefits of clustered indexes

Leveraging table partitioning

Nonclustered indexes in analytical scenarios

Using indexed views

Data compression and query techniques

Writing efficient queries

Columnar storage and batch processing

Columnar storage and compression

Recreating rows from columnar storage

Columnar storage creation process

Development of columnar storage in SQL Server

Batch processing

Nonclustered columnstore indexes

Compression and query performance

Testing the nonclustered columnstore index

Operational analytics

Clustered columnstore indexes

Compression and query performance

Testing the clustered columnstore index

Using archive compression

Adding B-tree indexes and constraints

Updating a clustered columnstore index

Deleting from a clustered columnstore index

Summary

SSIS Setup

Introduction

SQL Server 2016 download

Getting ready

How to do it...

Installing JRE for PolyBase

Getting ready

How to do it...

How it works...

Installing SQL Server 2016

Getting ready

How to do it...

SQL Server Management Studio installation

Getting ready

How to do it...

SQL Server Data Tools installation

Getting ready

How to do it...

Testing SQL Server connectivity

Getting ready

How to do it...

What Is New in SSIS 2016

Introduction

Creating SSIS Catalog

Getting ready

How to do it...

Custom logging

Getting ready

How to do it...

How it works...

There's more...

Create a database

Create a simple project

Testing the custom logging level

See also

Azure tasks and transforms

Getting ready

How to do it...

See also

Incremental package deployment

Getting ready

How to do it...

There's more...

Multiple version support

Getting ready

How to do it...

There's more...

Error column name

Getting ready

How to do it...

Control Flow templates

Getting ready

How to do it...

Key Components of a Modern ETL Solution

Introduction

Installing the sample solution

Getting ready

How to do it...

There's more...

Deploying the source database with its data

Getting ready

How to do it...

There's more...

Deploying the target database

Getting ready

How to do it...

SSIS projects

Getting ready

How to do it...

Framework calls in EP_Staging.dtsx

Getting ready

How to do it...

There's more...

Dealing with Data Quality

Introduction

Profiling data with SSIS

Getting ready

How to do it...

Creating a DQS knowledge base

Getting ready

How to do it...

Data cleansing with DQS

Getting ready

How to do it...

Creating a MDS model

Getting ready

How to do it...

Matching with DQS

Getting ready

How to do it...

Using SSIS fuzzy components

Getting ready

How to do it...

Unleash the Power of SSIS Script Task and Component

Introduction

Using variables in SSIS Script task

Getting ready

How to do it...

Execute complex filesystem operations with the Script task

Getting ready

How to do it...

Reading data profiling XML results with the Script task

Getting ready

How to do it...

Correcting data with the Script component

Getting ready

How to do it...

Validating data using regular expressions in a Script component

Getting ready

How to do it...

Using the Script component as a source

How to do it...

How it works...

Using the Script component as a destination

Getting ready

How to do it...

How it works...

On-Premises and Azure Big Data Integration

Introduction

Azure Blob storage data management

Getting ready

How to do it...

Installing a Hortonworks cluster

Getting ready

How to do it...

Copying data to an on-premises cluster

Getting ready

How to do it...

Using Hive – creating a database

Getting ready

How to do it...

There's more...

Transforming the data with Hive

Getting ready

How to do it...

There's more...

Transferring data between Hadoop and Azure

Getting ready

How to do it...

Leveraging a HDInsight big data cluster

Getting ready

How to do it...

There's more...

Managing data with Pig Latin

Getting ready

How to do it...

There's more...

Importing Azure Blob storage data

Getting ready

How to do it...

There's more...

Azure Data Factory and SSIS 

Extending SSIS Custom Tasks and Transformations

Introduction

Designing a custom task

Getting ready

How to do it...

How it works...

Designing a custom transformation

How to do it...

How it works...

Managing custom component versions

Getting ready

How to do it...

How it works...

Scale Out with SSIS 2017

Introduction

SQL Server 2017 download and setup

Getting ready

How to do it...

There's more...

SQL Server client tools setup

Getting ready

How to do it...

Configuring SSIS for scale out executions

Getting ready

How to do it...

There's more...

Executing a package using scale out functionality

Getting ready

How to do it...

Other Books You May Enjoy

Leave a review - let other readers know what you think

Preface

Mastering SQL Server 2017 brings in the power of R and Python for machine learning and containerization-based deployment on Windows and Linux. By knowing how to use the features of SQL Server 2017 to your advantage, you can build scalable applications and easily perform data integration and transformation.

After a quick recap of the features of SQL Server 2017, this Learning Path shows you how to use Query Store, columnstore indexes, and In-Memory OLTP in your applications. You'll then learn to integrate Python code in SQL Server and graph database implementations for development and testing. Next, you'll learn how to design and build SQL Server Integration Services (SSIS) data warehouse packages using SQL server data tools. You'll also learn to develop SSIS packages designed to maintain a data warehouse using data flow and other control flow tasks. 

By the end of this Learning Path, you'll have the required information to easily design efficient, high-performance database applications. You'll also have explored on-premises big data integration processes to create a classic data warehouse.

This Learning Path includes content from the following Packt products:

SQL Server 2017 Developer's Guide by Miloš Radivojević, Dejan Sarka, William Durkin

SQL Server 2017 Integration Services Cookbook by Christian Coté, Dejan Sarka, Matija Lah

Who This Book Is For

Database developers and solution architects looking to develop ETL solutions with SSIS, and who want to learn the new features and capabilities in SSIS 2017, will find this Learning Path very useful. It will also be valuable to advanced analysis practitioners, business intelligence developers, and database consultants dealing with performance tuning. Some basic understanding of database concepts and T-SQL is required to get the best out of this Learning Path.

What This Book Covers

Chapter 1, Introduction to SQL Server 2017, very briefly covers the most important features and enhancements, not just those for developers. The chapter shows the whole picture and points readers in the direction of where things are moving.

Chapter 2, SQL Server Tools, helps you understand the changes in the release management of SQL Server tools and explores small and handy enhancements in SQL Server Management Studio (SSMS). It also introduces RStudio IDE, a very popular tool for developing R code, and briefly covers SQL Server Data Tools (SSDT), including the new R Tools for Visual Studio (RTVS), a plugin for Visual Studio, which enables you to develop R code in an IDE that is popular among developers using Microsoft products and languages. The chapter introduces Visual Studio 2017 and shows how it can be used for data science applications with Python.

Chapter 3, JSON Support in SQL Server, explores the JSON support built into SQL Server. This support should make it easier for applications to exchange JSON data with SQL Server.

Chapter 4, Stretch Database, helps you understand how to migrate historical or less frequently/infrequently accessed data transparently and securely to Microsoft Azure using the Stretch Database (Stretch DB) feature.

Chapter 5, Temporal Tables, introduces support for system-versioned temporal tables based on the SQL:2011 standard. We explain how this is implemented in SQL Server and demonstrate some use cases for it (for example, a time-travel application).

Chapter 6, Columnstore Indexes, revises columnar storage and then explores the huge improvements relating to columnstore indexes in SQL Server 2016: updatable non-clustered columnstore indexes, columnstore indexes on in-memory tables, and many other new features for operational analytics.

Chapter 7, SSIS Setup, contains recipes describing the step by step setup of SQL Server 2016 to get the features that are used in the book.

Chapter 8, What Is New in SSIS 2016, contains recipes that talk about the evolution of SSIS over time and what's new in SSIS 2016. This chapter is a detailed overview of Integration Services 2016, new features.

Chapter 9, Key Components of a Modern ETL Solution, explains how ETL has evolved over the past few years and will explain what components are necessary to get a modern scalable ETL solution that fits the modern data warehouse. This chapter will also describe what each catalog view provides and will help you learn how you can use some of them to archive SSIS execution statistics.

Chapter 10, Dealing with Data Quality, focuses on how SSIS can be leveraged to validate and load data. You will learn how to identify invalid data, cleanse data and load valid data to the data warehouse.

Chapter 11,  Unleash the Power of SSIS Script Task and Component, covers how to use scripting with SSIS. You will learn how script tasks and script components are very valuable in many situations to overcome the limitations of stock toolbox tasks and transforms.

Chapter 12, On-Premises and Azure Big Data Integration, describes the Azure feature pack that allows SSIS to integrate Azure data from blob storage and HDInsight clusters. You will learn how to use Azure feature pack components to add flexibility to their SSIS solution architecture and integrate on-premises Big Data can be manipulated via SSIS.

Chapter 13, Extending SSIS Tasks and Transformations, talks about extending and customizing the toolbox using custom-developed tasks and transforms and security features. You will learn the pros and cons of creating custom tasks to extend the SSIS toolbox and secure your deployment.

Chapter 14, Scale Out with SSIS 2017, talks about scaling out SSIS package executions on multiple servers. You will learn how SSIS 2017 can scale out to multiple workers to enhance execution scalability.

To Get the Most out of This Book

In order to run all of the demo code in this book, you will need SQL Server 2017 Developer or Enterprise Edition. In addition, you will extensively use SQL Server Management Studio.

You will also need the RStudio IDE and/or SQL Server Data Tools with R Tools for Visual Studio plug-in

SQL Server 2017 Developer or Enterprise Edition.

In addition, you will extensively use SQL Server Management Studio.

 

Other tools you may need are Visual Studio 2015, SQL Data Tools 16 or higher and SQL Server Management Studio 17 or later.

In addition to that, you will need Hortonworks Sandbox Docker for Windows Azure account and Microsoft Azure.

Download the Example Code Files

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.

Hover the mouse pointer on the

 

SUPPORT

 

tab at the top.

Click on

 

Code Downloads & Errata

.

Enter the name of the book in the

 

Search

 

box.

Select the book for which you're looking to download the code files.

Choose from the drop-down menu where you purchased this book from.

Click on

 

Code Download

.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account. Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for Windows

Zipeg / iZip / UnRarX for Mac

7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-SQL-Server-2017-. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781838983208_ColorImages.pdf.

Get in Touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com

Introduction to SQL Server 2017

SQL Server is the main relational database management system product from Microsoft. It has been around in one form or another since the late 80s (developed in partnership with Sybase), but as a standalone Microsoft product, it's been here since the early 90s. In the last 20 years, SQL Server has changed and evolved, gaining newer features and functionality along the way.

The SQL Server we know today is based on what was arguably the most significant (r)evolutionary step in its history: the release of SQL Server 2005. The changes that were introduced allowed the versions that followed the 2005 release to take advantage of newer hardware and software improvements, such as: 64-bit memory architecture, better multi-CPU and multi-core support, better alignment with the .NET framework, and many more modernizations in general system architecture.

The incremental changes introduced in each subsequent version of SQL Server have continued to improve upon this solid new foundation. Fortunately, Microsoft has changed the release cycle for multiple products, including SQL Server, resulting in shorter time frames between releases. This has, in part, been due to Microsoft's focus on their much reported Mobile first, Cloud first strategy. This strategy, together with the development of the cloud version of SQL Server Azure SQL Database, has forced Microsoft into a drastically shorter release cycle. The advantage of this strategy is that we are no longer required to wait 3 to 5 years for a new release (and new features). There have been releases every 2 years since SQL Server 2012 was introduced, with multiple releases of Azure SQL Database in between the real versions.

While we can be pleased that we no longer need to wait for new releases, we are also at a distinct disadvantage. The rapid release of new versions and features leaves us developers with ever-decreasing periods of time to get to grips with the shiny new features. Prior versions had multiple years between releases, allowing us to build up a deeper knowledge and understanding of the available features, before having to consume new information.

Following on from the release of SQL Server 2016 was the release of SQL Server 2017, barely a year after 2016 was released. Many features were merely more polished/updated versions of the 2016 release, while there were some notable additions in the 2017 release.

In this chapter (and book), we will introduce what is new inside SQL Server 2017. Due to the short release cycle, we will outline features that are brand new in this release of the product and look at features that have been extended or improved upon since SQL Server 2016.

We will be outlining the new features in the following areas:

Security

Engine features

Programming

Business intelligence

Security

The last few years have made the importance of security in IT extremely apparent, particularly when we consider the repercussions of the Edward Snowden data leaks or multiple cases of data theft via hacking. While no system is completely impenetrable, we should always be considering how we can improve the security of the systems we build. These considerations are wide ranging and sometimes even dictated via rules, regulations, and laws. Microsoft has responded to the increased focus on security by delivering new features to assist developers and DBAs in their search for more secure systems.

Row-Level Security

The first technology that was introduced in SQL Server 2016 to address the need for increased/improved security is Row-Level Security (RLS). RLS provides the ability to control access to rows in a table based on the user executing a query. With RLS it is possible to implement a filtering mechanism on any table in a database, completely transparently to any external application or direct T-SQL access.

The ability to implement such filtering without having to redesign a data access layer allows system administrators to control access to data at an even more granular level than before. The fact that this control can be achieved without any application logic redesign makes this feature potentially even more attractive to certain use-cases. RLS also makes it possible, in conjunction with the necessary auditing features, to lock down a SQL Server database so that even the traditional god-mode sysadmin cannot access the underlying data.

Dynamic data masking

The second security feature that we will be covering is Dynamic Data Masking (DDM). DDM allows the system administrator to define column level data masking algorithms that prevent users from reading the contents of columns, while still being able to query the rows themselves. This feature was initially aimed at allowing developers to work with a copy of production data without having the ability to actually see the underlying data. This can be particularly useful in environments where data protection laws are enforced (for example, credit card processing systems and medical record storage). Data masking occurs only at query runtime and does not affect the stored data of a table. This means that it is possible to mask a multi-terabyte database through a simple DDL statement, rather than resorting to the previous solution of physically masking the underlying data in the table we want to mask. The current implementation of DDM provides the ability to define a fixed set of functions to columns of a table, which will mask data when a masked table is queried. If a user has the permission to view the masked data, then the masking functions are not run, whereas a user who may not see masked data will be provided with the data as seen through the defined masking functions.

Always Encrypted

The third major security feature to be introduced in SQL Server 2016 is Always Encrypted. Encryption with SQL Server was previously a (mainly) server-based solution. Databases were either protected with encryption at the database level (the entire database was encrypted) or at the column level (single columns had an encryption algorithm defined). While this encryption was/is fully functional and safe, crucial portions of the encryption process (for example, encryption certificates) are stored inside SQL Server. This effectively gave the owner of a SQL Server instance the ability to potentially gain access to this encrypted data—if not directly, there was at least an increased surface area for a potential malicious access attempt. As ever more companies moved into hosted service and cloud solutions (for example, Microsoft Azure), the previous encryption solutions no longer provided the required level of control/security.

Always Encrypted was designed to bridge this security gap by removing the ability of an instance owner to gain access to the encryption components. The entirety of the encryption process was moved outside of SQL Server and resides on the client side. While a similar effect was possible using homebrew solutions, Always Encrypted provides a fully integrated encryption suite into both the .Net Framework and SQL Server. Whenever data is defined as requiring encryption, the data is encrypted within the .NET framework and only sent to SQL Server after encryption has occurred. This means that a malicious user (or even system administrator) will only ever be able to access encrypted information should they attempt to query data stored via Always Encrypted.

Microsoft has made some positive progress in this area of the product. While no system is completely safe and no single feature can provide an all-encompassing solution, all three features provide a further option in building up, or improving upon, any system's current security level. 

Engine features

The Engine features section is traditionally the most important, or interesting, for most DBAs or system administrators when a new version of SQL Server is released. However, there are also numerous engine feature improvements that have tangential meanings for developers too. So, if you are a developer, don't skip this section—or you may miss some improvements that could save you some trouble later on!

Query Store

The Query Store is possibly the biggest new engine feature to come with the release of SQL Server 2016. DBAs and developers should be more than familiar with the situation of a query behaving reliably for a long period, which suddenly changed into a slow-running, resource-killing monster. Some readers may identify the cause of the issue as the phenomenon of parameter sniffing or similarly through stale statistics. Either way, when troubleshooting to find out why one unchanging query suddenly becomes slow, knowing the query execution plan(s) that SQL Server has created and used can be very helpful. A major issue when investigating these types of problems is the transient nature of query plans and their execution statistics. This is where Query Store comes into play; SQL Server collects and permanently stores information on query compilation and execution on a per-database basis. This information is then persisted inside each database that is being monitored by the Query Store functionality, allowing a DBA or developer to investigate performance issues after the fact.

It is even possible to perform longer-term query analysis, providing an insight into how query execution plans change over a longer time frame. This sort of insight was previously only possible via handwritten solutions or third-party monitoring solutions, which may still not allow the same insights as the Query Store does.

Live query statistics

When we are developing inside SQL Server, each developer creates a mental model of how data flows inside SQL Server. Microsoft has provided a multitude of ways to display this concept when working with query execution. The most obvious visual aid is the graphical execution plan. There are endless explanations in books, articles, and training seminars that attempt to make reading these graphical representations easier. Depending upon how your mind works, these descriptions can help or hinder your ability to understand the data flow concepts—fully blocking iterators, pipeline iterators, semi-blocking iterators, nested loop joins... the list goes on. When we look at an actual graphical execution plan, we are seeing a representation of how SQL Server processed a query: which data retrieval methods were used, which join types were chosen to join multiple data sets, what sorting was required, and so on. However, this is a representation after the query has completed execution. Live Query Statistics offers us the ability to observe during query execution and identify how, when, and where data moves through the query plan. This live representation is a huge improvement in making the concepts behind query execution clearer and is a great tool to allow developers to better design their query and index strategies to improve query performance.

Further details of Live Query Statistics can be found in Chapter 2, SQL Server Tools.

Stretch Database

Microsoft has worked a lot in the past few years on their Mobile First, Cloud First strategy. We have seen a huge investment in their cloud offering, Azure, with the line between on-premises IT and cloud-based IT being continually blurred. The features being released in the newest products from Microsoft continue this approach and SQL Server is taking steps to bridge the divide between running SQL Server as a fully on-premises solution and storing/processing relational data in the cloud.

One big step in achieving this approach is the new Stretch Database feature with SQL Server 2016. Stretch Database allows a DBA to categorize the data inside a database, defining which data is hot and which is cold. This categorization allows Stretch Database to then move the cold data out of the on-premises database and into Azure Cloud Storage.

The segmentation of data remains transparent to any user/application that queries the data, which now resides in two different locations. The idea behind this technology is to reduce storage requirements for the on-premises system by offloading large amounts of archive data onto cheaper, slower storage in the cloud.

This reduction should then allow the smaller hot data to be placed on smaller capacity, higher performance storage. The magic of Stretch Database is the fact that this separation of data requires no changes at the application or database query level. This is a purely storage-level change, which means the potential ROI of segmenting a database is quite large.

Further details of Stretch Database can be found in Chapter 4, Stretch Database.

Database scoped configuration

Many DBAs who support multiple third-party applications running on SQL Server can experience the difficulty of setting up their SQL Server instances per the application requirements or best practices. Many third-party applications have prerequisites that dictate how the actual instance of SQL Server must be configured. A common occurrence is a requirement of configuring the Max Degree of Parallelism to force only one CPU to be used for query execution. As this is an instance-wide setting, this can affect all other databases/applications in a multi-tenant SQL Server instance (which is generally the case). With Database Scoped Configuration in SQL Server 2016, several previously instance-level settings have been moved to a database-level configuration option. This greatly improves multi-tenant SQL Server instances, as the decision of, for example, how many CPUs can be used for query execution can be made at the database-level, rather than for the entire instance. This will allow DBAs to host databases with differing CPU usage requirements on the same instance, rather than having to either impact the entire instance with a setting or be forced to run multiple instances of SQL Server and possibly incur higher licensing costs.

Temporal Tables

There are many instances where DBAs or developers are required to implement a change tracking solution, allowing future analysis or assessment of data changes for certain business entities. A readily accessible example is the change in history on a customer account in a CRM system. The options for implementing such a change tracking system are varied and have strengths and weaknesses. One such implementation that has seen wide adoption is the use of triggers, to capture data changes and store historical values in an archive table. Regardless of the implementation chosen, it was often cumbersome to be able to develop and maintain these solutions.

One of the challenges was in being able to incorporate table structure changes in the table being tracked. It was equally challenging creating solutions to allow for querying both the base table and the archive table belonging to it. The intelligence of deciding whether to query the live and/or archive data can require some complex query logic.

With the advent of Temporal Tables, this entire process has been simplified for both developers and DBAs. It is now possible to activate this change tracking on a table and push changes into an archive table with a simple change on a table's structure. Querying the base table and including a temporal attribute to the query is also a simple T-SQL syntax addition. As such, it is now possible for a developer to submit temporal analysis queries, and SQL Server takes care of splitting the query between the live and archive data and returning the data in a single result set.

Further details of Temporal Tables can be found in Chapter 5, Temporal Tables.

Columnstore indexes

Traditional data storage inside SQL Server has used the row-storage format, where the data for an entire row is stored together on the data pages inside the database. SQL Server 2012 introduced a new storage format: columnstore. This format pivots the data storage, combining the data from a single column and storing the data together on the data pages. This storage format provides the ability of massive compression of data; it's orders of magnitude better than traditional row storage.

Initially, only non-clustered columnstore indexes were possible. With SQL Server 2014, clustered columnstore indexes were introduced, expanding the usability of the feature greatly. Finally, with SQL Server 2016, updateable columnstore indexes and support for In-Memory columnstore indexes have been introduced. The potential performance improvements through these improvements are huge.

Further details of columnstore indexes can be found in Chapter 6, Columnstore Indexes.

Containers and SQL Server on Linux 

For the longest time, SQL Server has run solely on the Windows operating system. This was a major roadblock for adoption in traditionally Unix/Linux based companies that used alternative RDBM systems instead. Containers have been around in IT for over a decade and have made a major impression in the application development world. The ability to now host SQL Server in a container provides developers with the ability to adopt the development and deployment methodologies associated with containers into database development. A second major breakthrough (and surprise) around SQL Server 2017 was the announcement of SQL Server being ported to Linux. The IT world was shocked at this revelation and what it meant for the other RDBM systems on the market. There is practically no other system with the same feature-set and support network available at the same price point. As such, SQL Server on Linux will open a new market and allow for growth in previously unreachable areas of the IT world.

This concludes the section outlining the engine features. Through Microsoft's heavy move into cloud computing and their Azure offerings, they have had increased need to improve their internal systems for themselves. Microsoft has been famous for its dogfooding approach of using their own software to run their own business and Azure is arguably their largest foray into this area. The main improvements in the database engine have been fueled by the need to improve their own ability to continue offering Azure database solutions at a scale and provide features to allow databases of differing sizes and loads to be hosted together.

Programming

Without programming, a SQL Server isn't very useful. The programming landscape of SQL Server has continued to improve to adopt newer technologies over the years. SQL Server 2017 is no exception in this area. There have been some long-awaited general improvements and also some rather revolutionary additions to the product that changes the way SQL Server can be used in future projects. This section will outline what programming improvements have been included in SQL Server 2017.

Transact-SQL enhancements

The last major improvements in the T-SQL language allowed for better processing of running totals and other similar window functions. This was already a boon and allowed developers to replace arcane cursors with high-performance T-SQL. These improvements are never enough for the most performance conscious developers among us, and as such there were still voices requesting further incorporation of the ANSI SQL standards into the T-SQL implementation.

Notable additions to the T-SQL syntax include the ability to finally split comma-separated strings using a single function call, STRING_SPLIT(), instead of the previous hacky implementations using loops or the Common Language Runtime (CLR).

The sensible opposing syntax for splitting strings is a function to aggregate values together, STRING_AGG(), which returns a set of values in a comma-separated string. This replaces similarly hacky solutions using the XML data type of one of a multitude of looping solutions.

Each improvement in the T-SQL language further extends the toolbox that we, as developers, possess to be able to manipulate data inside SQL Server. The ANSI SQL standards provide a solid basis to work from and further additions of these standards are always welcome.

JSON

It is quite common to meet developers outside of the Microsoft stack who look down on products from Redmond. Web developers, in particular, have been critical of the access to modern data exchange structures, or rather the lack of it. JSON has become the de facto data exchange method for the application development world. It is similar in structure to the previous cool-kid XML, but for reasons beyond the scope of this book, JSON has overtaken XML and is the expected payload for application and database communications.

Microsoft has included JSON as a native data type in SQL Server 2016 and provided a set of functions to accompany the data type.

Further details of JSON can be found in Chapter 3, JSON Support in SQL Server.

In-Memory OLTP

In-Memory OLTP (codename Hekaton) was introduced in SQL Server 2014. The promise of ultra-high performance data processing inside SQL Server was a major feature when SQL Server 2014 was released. As expected with version-1 features, there were a wide range of limitations in the initial release and this prevented many customers from being able to adopt the technology. With SQL Server 2017, a great number of these limitations have been either raised to a higher threshold or completely removed. In-Memory OLTP has received the required maturity and extension in feature set to make it viable for prime production deployment. 

SQL Server Tools

Accessing or managing data inside SQL Server and developing data solutions are two separate disciplines, each with their own specific focus on SQL Server. As such, Microsoft has created two different tools, each tailored towards the processes and facets of these disciplines.

SQL Server Management Studio (SSMS), as the name suggests, is the main management interface between DBAs/developers and SQL Server. The studio was originally released with SQL Server 2005 as a replacement and consolidation of the old Query Analyzer and Enterprise Manager tools. As with any non-revenue-generating software, SSMS only received minimal attention over the years, with limitations and missing tooling for many of the newer features in SQL Server. With SQL Server 2016, the focus of Microsoft has shifted and SSMS has been de-coupled from the release cycle of SQL Server itself. This decoupling allows both SSMS and SQL Server to be developed without having to wait for each other or for release windows. New releases of SSMS are created on top of more recent versions of Visual Studio and have seen almost monthly update releases since SQL Server 2016 was released into the market.

SQL Server Data Tools (SSDT) is also an application based on the Visual Studio framework. SSDT is focused on the application/data development discipline. SSDT is much more closely aligned with Visual Studio in its structure and the features offered. This focus includes the ability to create entire database projects and solution files, easier integration into source control systems, the ability to connect projects into automated build processes, and generally offering a developer-centric development environment with a familiarity with Visual Studio. It is possible to design and create solutions in SSDT for SQL Server using the Relational Engine, Analysis Services, Integration Services, Reporting Services, and of course the Azure SQL database.

Further details of SQL Server Tools can be found in Chapter 2, SQL Server Tools.

This concludes the overview of programming enhancements inside SQL Server 2016. The improvements outlined are all solid evolutionary steps in their respective areas. New features are very welcome and allow us to achieve more while requiring less effort on our side. The In-memory OLTP enhancements are especially positive, as they now expand on the groundwork laid down in the release of SQL Server 2014. Please read the respective chapters to gain deeper insight into how these enhancements can help you.

Business intelligence

Business intelligence is a huge area of IT and has been a cornerstone of the SQL Server product since at least SQL Server 2005. As the market and technologies in the business intelligence space improve, so must SQL Server. The advent of cloud-based data analysis systems as well as the recent buzz around big data are driving forces for all data platform providers, and Microsoft is no exception here. While there are multiple enhancements in the business intelligence portion of SQL Server 2016, we will be concentrating on the feature that has a wider audience than just data analysts: the R language in SQL Server.

R in SQL server

Data analytics has been the hottest topic in IT for the past few years, with new niches being crowned as the pinnacles of information science almost as fast as technology can progress. However, IT does have a few resolute classics that have stood the test of time and are still in widespread use. SQL (in its many permutations) is a language we are well aware of in the SQL Server world. Another such language is the succinctly titled R. The R language is a data mining, machine learning, and statistical analysis language that has existed since 1993.

Many professionals such as data scientists, data analysts, or statisticians have been using the R language and tools that belong in that domain for a similarly long time. Microsoft has identified that although they may want all of the world's data inside SQL Server, this is just not feasible or sensible. External data sources and languages like R exist and they need to be accessible in an integrated manner.

For this to work, Microsoft made the decision to purchase Revolution Analytics (a commercial entity producing the forked Revolution R) in 2015 and was then able to integrate the language and server process into SQL Server 2016. This integration allows a normal T-SQL developer to interact with the extremely powerful R service in a native manner and allows more advanced data analysis to be performed on their data.

Release cycles

Microsoft has made a few major public-facing changes in the past 5 years. These changes include a departure from longer release cycles in their main products and a transition towards subscription-based services (for example, Office 365 and Azure services). The ideas surrounding continuous delivery and agile software development have also shaped the way that Microsoft has been delivering on its flagship integrated development environment Visual Studio, with releases occurring approximately every six months. This change in philosophy is now flowing into the development cycle of SQL Server. Due to the similarly constant release cycle of the cloud version of SQL Server (Azure SQL Database), there is a desire to keep both the cloud and on-premises versions of the product as close to each other as possible. As such, it is unsurprising to see that the previous release cycle of every three to 5 years is being replaced with much shorter intervals. A clear example of this is that SQL Server 2016 released to the market in June of 2016, with a Community Technology Preview (CTP) of SQL Server 2017 being released in November of 2016 and the Release To Market (RTM) of SQL Server 2017 happening in October 2017. The wave of technology progress stops for no one. This is very clearly true in the case of SQL Server!

Summary

In this introductory chapter, we saw a brief outline of what will be covered in this book. Each version of SQL Server has hundreds of improvements and enhancements, both through new features and through extensions on previous versions. The outlines for each chapter provide an insight into the main topics covered in this book and allow you to identify which areas you may like to dive into and where to find them.

So let's get going with the rest of the book and see what SQL Server 2017 has to offer.

SQL Server Tools

As developers, we are accustomed to using Integrated Development Environments (IDEs) in our software projects. Visual Studio has been a major player in the IDE space for many years, if not decades, and it has allowed developers to use the latest software development processes to further improve quality and efficiency in software projects. Server management, on the other hand, has generally been a second-class citizen for many products in the past. In general, this fact can be understood, if not agreed with. IDEs are tools that design and create software that can generate revenue for a business, whereas management tools generally only offer the benefit of some sort of cost-saving, rather than direct revenue generation.

The SQL Server Tools of the past (pre-SQL 2005) were very much focused on fulfilling the requirements of being able to manage and query SQL Server instances and databases but received no great investments in making the tools comfortable or even enjoyable to use. Advanced IDEs were firmly in the application development domain and application developers know that databases are a storage system at best and therefore require no elegant tooling to be worked with.

Luckily for us, the advent of SQL Server 2005, along with the release of the .NET Framework, encouraged some people at Microsoft to invest a little more time and resources in providing an improved interface for both developers and DBAs for database and data management purposes. The SQL Server Management Studio (SSMS) was born and unified the functionality of two legacy tools: Query Analyzer and Enterprise Manager. Anyone who has worked with SQL Server since the 2005 release will recognize the application regardless of whether they are using the 2005 release or the latest 2016 build.

There have been several different names and releases of the second tool in this chapter, SQL Server Data Tools (SSDT), going back to SQL Server 2005/2008 where the tool was known under the name Visual Studio Database Projects (that is, Data Dude). The many incarnations of this tool since SQL Server 2005 have been focused on the development of database projects. The SSDT has many of the tools and interfaces known to Visual Studio users and allows a seasoned Visual Studio user to quickly familiarize themselves with the tool. Particularly interesting is the improved ability to integrate database and business intelligence projects into source control and continuous integration and automated deployment processes.

In this chapter, we will be exploring:

Installing and updating SQL Server Tools

New SSMS features and enhancements

SQL Server Data Tools

Tools for developing R and Python code

Installing and updating SQL Server Tools

The very beginning of our journey with SQL Server is the installation process. In previous versions of SQL Server, the data management and development tools were delivered together with the SQL Server installation image. As such, if a developer wanted to install SSMS, the setup of SQL Server had to be used to facilitate the installation.

As of SQL Server 2016, Microsoft made the very smart decision to separate the management tools from the server installation. This is not only a separation of the installation medium but also a separation of the release process. This separation means that both products can be developed and released without having to wait for the other team to be ready. Let's take a look at how this change affects us at installation time.

In the following screenshot, given as follows, we see the SQL Server Installation Centerscreen. This is the first screen we will encounter when running the SQL Server setup.exe shown in the installation screenshot. After choosing the Installation menu point on the left, we are confronted with the generic installation options of SQL Server, which have only minimally changed in the last releases. The second and third options presented on this screen are Install SQL Server Management Tools and Install SQL Server Data Tools. If we read the descriptions of these options, we note that both links will redirect us to the Downloads page for either SSMS or SSDT. This is the first clear indication that the delivery of these tools has now been decoupled from the server installation:

SQL Server Installation Center

After clicking Install SQL Server Management Studio, you should be redirected to the Downloads page, which should look like the following screenshot:

SQL Server Management Studio download page

The Downloads page offers us the latest production version of SSMS on the main page, together with any upgrade packages for previous versions of the software. We are also able to see details on the current release and view, download previous releases, and find information on change logs and release notes on the left of the web page:

SQL Server Management Studio setup dialogue