SQL Server 2016 Developer's Guide

Book description

Get the most out of the rich development capabilities of SQL Server 2016 to build efficient database applications for your organization

About This Book

  • Utilize the new enhancements in Transact-SQL and security features in SQL Server 2016 to build efficient database applications
  • Work with temporal tables to get information about data stored in the table at any point in time
  • A detailed guide to SQL Server 2016, introducing you to multiple new features and enhancements to improve your overall development experience

Who This Book Is For

This book is for database developers and solution architects who plan to use the new SQL Server 2016 features for developing efficient database applications. It is also ideal for experienced SQL Server developers who want to switch to SQL Server 2016 for its rich development capabilities. Some understanding of the basic database concepts and Transact-SQL language is assumed.

What You Will Learn

  • Explore the new development features introduced in SQL Server 2016
  • Identify opportunities for In-Memory OLTP technology, significantly enhanced in SQL Server 2016
  • Use columnstore indexes to get significant storage and performance improvements
  • Extend database design solutions using temporal tables
  • Exchange JSON data between applications and SQL Server in a more efficient way
  • Migrate historical data transparently and securely to Microsoft Azure by using Stretch Database
  • Use the new security features to encrypt or to have more granular control over access to rows in a table
  • Simplify performance troubleshooting with Query Store
  • Discover the potential of R’s integration with SQL Server

In Detail

Microsoft SQL Server 2016 is considered the biggest leap in the data platform history of the Microsoft, in the ongoing era of Big Data and data science. Compared to its predecessors, SQL Server 2016 offers developers a unique opportunity to leverage the advanced features and build applications that are robust, scalable, and easy to administer.

This book introduces you to new features of SQL Server 2016 which will open a completely new set of possibilities for you as a developer. It prepares you for the more advanced topics by starting with a quick introduction to SQL Server 2016’s new features and a recapitulation of the possibilities you may have already explored with previous versions of SQL Server. The next part introduces you to small delights in the Transact-SQL language and then switches to a completely new technology inside SQL Server - JSON support. We also take a look at the Stretch database, security enhancements, and temporal tables.

The last chapters concentrate on implementing advanced topics, including Query Store, columnstore indexes, and In-Memory OLTP. You will finally be introduced to R and how to use the R language with Transact-SQL for data exploration and analysis.

By the end of this book, you will have the required information to design efficient, high-performance database applications without any hassle.

Style and approach

This book is a detailed guide to mastering the development features offered by SQL Server 2016, with a unique learn-as-you-do approach. All the concepts are explained in a very easy-to-understand manner and are supplemented with examples to ensure that you—the developer—are able to take that next step in building more powerful, robust applications for your organization with ease.

Table of contents

  1. SQL Server 2016 Developer's Guide
    1. SQL Server 2016 Developer's Guide
    2. Credits
    3. About the Authors
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Customer Feedback
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Introduction to SQL Server 2016
      1. Security
        1. Row Level Security
        2. Dynamic Data Masking
        3. Always Encrypted
      2. Engine features
        1. Query Store
        2. Live Query Statistics
        3. Stretch Database
        4. Database scoped configuration
        5. Temporal Tables
        6. Columnstore indexes
      3. Programming
        1. Transact SQL enhancements
        2. JSON
        3. In-Memory OLTP
        4. SQL Server tools
      4. Business intelligence
        1. R in SQL Server
      5. Release cycles
      6. Summary
    9. 2. Review of SQL Server Features for Developers
      1. The mighty Transact-SQL SELECT
        1. Core Transact-SQL SELECT statement elements
        2. Advanced SELECT techniques
      2. DDL, DML, and programmable objects
        1. Data definition language statements
        2. Data modification language statements
        3. Using triggers
        4. Data abstraction - views, functions, and stored procedures
      3. Transactions and error handling
        1. Error handling
        2. Using transactions
      4. Beyond relational
        1. Defining locations and shapes with Spatial Data
        2. CLR integration
        3. XML support in SQL Server
      5. Summary
    10. 3. SQL Server Tools
      1. Installing and updating SQL Server tools
      2. New SSMS features and enhancements
        1. Autosave open tabs
        2. Searchable options
        3. Enhanced scroll bar
        4. Execution plan comparison
        5. Live Query Statistics
      3. SQL Server Data Tools
      4. Tools for developing R code
        1. RStudio IDE
        2. R Tools for Visual Studio
      5. Summary
    11. 4. Transact-SQL Enhancements
      1. New and enhanced functions and expressions
        1. STRING_SPLIT
        2. STRING_ESCAPE
        3. COMPRESS
        4. DECOMPRESS
        5. CURRENT_TRANSACTION_ID
        6. SESSION_CONTEXT
        7. DATEDIFF_BIG
        8. AT TIME ZONE
        9. HASHBYTES
        10. JSON functions
      2. Enhanced DML and DDL statements
        1. The conditional DROP statement (DROP IF EXISTS)
        2. CREATE OR ALTER
        3. Online Alter Column
        4. TRUNCATE TABLE
        5. Maximum key size for nonclustered indexes
      3. New query hints
        1. NO_PERFORMANCE_SPOOL
        2. MAX_GRANT_PERCENT
        3. MIN_GRANT_PERCENT
      4. Summary
    12. 5. JSON Support in SQL Server
      1. Why JSON?
      2. What is JSON?
        1. Why is it popular?
        2. JSON versus XML
        3. JSON objects
          1. JSON object
          2. JSON array
          3. Primitive JSON data types
      3. JSON in SQL Server prior to SQL Server 2016
        1. JSON4SQL
        2. JSON.SQL
        3. Transact-SQL-based solution
      4. Retrieving SQL Server data in the JSON format
        1. FOR JSON AUTO
        2. FOR JSON PATH
          1. FOR JSON additional options
            1. Adding a root node to the JSON output
            2. Including null values in the JSON output
            3. Formatting a JSON output as a single object
        3. Converting data types
        4. Escaping characters
      5. Converting JSON data in a tabular format
        1. OPENJSON with the default schema
          1. Processing data from a comma-separated list of values
          2. Returning the difference between two table rows
        2. OPENJSON with an explicit schema
        3. Import the JSON data from a file
      6. JSON storage in SQL Server 2016
      7. Validating JSON data
      8. Extracting values from a JSON text
        1. JSON_VALUE
        2. JSON_QUERY
      9. Modifying JSON data
        1. Adding a new JSON property
        2. Updating the value for a JSON property
        3. Removing a JSON property
        4. Multiple changes
      10. Performance considerations
        1. Indexes on computed columns
        2. Full-text indexes
      11. Summary
    13. 6. Stretch Database
      1. Stretch Database architecture
        1. Is this for you?
          1. Using Data Migration Assistant
      2. Limitations of using Stretch Database
        1. Limitations that prevent you from enabling the Stretch DB feature for a table
          1. Table limitations
          2. Column limitations
        2. Limitations for Stretch-enabled tables
      3. Use cases for Stretch Database
        1. Archiving of historical data
        2. Archiving of logging tables
        3. Testing Azure SQL database
      4. Enabling Stretch Database
        1. Enabling Stretch Database at the database level
          1. Enabling Stretch Database by using wizard
          2. Enabling Stretch Database by using Transact-SQL
        2. Enabling Stretch Database for a table
          1. Enabling Stretch DB for a table by using wizard
          2. Enabling Stretch Database for a table by using Transact-SQL
          3. Filter predicate with sliding window
      5. Querying Stretch Databases
        1. Querying and updating remote data
      6. SQL Server Stretch Database pricing
      7. Stretch DB management and troubleshooting
        1. Monitoring Stretch Database
        2. Pause and resume data migration
        3. Disable Stretch Database
          1. Disable Stretch Database for tables by using SSMS
          2. Disable Stretch Database for tables using Transact-SQL
          3. Disable Stretch Database for a database
        4. Backup and restore Stretch-enabled databases
      8. Summary
    14. 7. Temporal Tables
      1. What is temporal data?
        1. Types of temporal table
        2. Allen's interval algebra
        3. Temporal constraints
        4. Temporal data in SQL Server before 2016
        5. Optimizing temporal queries
        6. Temporal features in SQL:2011
      2. System-versioned tables in SQL Server 2016
        1. How temporal tables work in SQL Server 2016
        2. Creating temporal tables
          1. Period columns as hidden attributes
            1. Converting non-temporal to temporal tables
            2. Migration existing temporal solution to system-versioned tables
        3. Altering temporal tables
        4. Dropping temporal tables
        5. Data manipulation in temporal tables
        6. Querying temporal data in SQL Server 2016
          1. Retrieving temporal data at a specific point in time
          2. Retrieving temporal data from a specific period
          3. Retrieving all temporal data
        7. Performance and storage considerations with temporal tables
          1. History data retention
      3. History table physical implementation
        1. History table overhead
        2. Temporal tables with memory-optimized tables
      4. What is missing in SQL Server 2016?
        1. SQL Server 2016 temporal tables and data warehouses
      5. Summary
    15. 8. Tightening the Security
      1. SQL Server security basics
        1. Defining principals and securables
        2. Managing schemas
        3. Object and statement permissions
      2. Encrypting the data
        1. Leveraging SQL Server data encryption options
        2. Always Encrypted
      3. Row-Level security
        1. Using programmable objects to maintain security
        2. Predicate-based Row-Level Security
      4. Exploring dynamic data masking
        1. Defining masked columns
        2. Dynamic data masking limitations
      5. Summary
    16. 9. Query Store
      1. Why Query Store?
      2. What is Query Store?
      3. Query Store architecture
      4. Enabling and configuring Query Store
        1. Enabling Query Store with SSMS
        2. Enabling Query Store with Transact-SQL
        3. Configuring Query Store
          1. Query Store default configuration
          2. Query Store Recommended Configuration
      5. Disabling and cleaning Query Store
      6. Query Store in action
        1. Capturing Query info
        2. Capturing plan info
        3. Collecting runtime statistics
        4. Query Store and migration
          1. Query Store – identifying regressed queries
          2. Query Store - fixing regressed queries
      7. Query Store reports in SQL Server management studio
        1. Regressed queries
        2. Top resource consuming queries tab
        3. Overall resource consumption
      8. Query Store use cases
        1. SQL Server version upgrades and patching
        2. Application and service releases, patching, failovers, and cumulative updates
        3. Identifying ad hoc queries
        4. Identifying unfinished queries
      9. Summary
    17. 10. Columnstore Indexes
      1. Analytical queries in SQL Server
        1. Joins and indexes
          1. Benefits of clustered indexes
          2. Leveraging table partitioning
          3. Nonclustered indexes in analytical scenarios
          4. Using indexed views
        2. Data compression and query techniques
          1. Writing efficient queries
      2. Columnar storage and batch processing
        1. Columnar storage and compression
          1. Recreating rows from columnar storage
          2. Columnar storage creation process
          3. Development of columnar storage in SQL Server
        2. Batch processing
      3. Nonclustered columnstore indexes
        1. Compression and query performance
          1. Testing the nonclustered columnstore Index
        2. Operational analytics
      4. Clustered columnstore indexes
        1. Compression and query performance
          1. Testing the clustered columnstore Index
          2. Using archive compression
        2. Adding B-Tree indexes and constraints
        3. Updating a clustered columnstore index
          1. Deleting from a clustered columnstore index
      5. Summary
    18. 11. Introducing SQL Server In-Memory OLTP
      1. In-Memory OLTP architecture
        1. Row and index storage
          1. Row structure
          2. Row header
        2. Row payload
        3. Index structure
          1. Non-clustered Index
          2. Hash indexes
      2. Creating memory-optimized tables and indexes
        1. Laying the foundation
        2. Creating a table
      3. Querying and data manipulation
        1. Performance comparisons
        2. Natively compiled stored procedures
        3. Looking behind the curtain of concurrency
      4. Data durability concerns
      5. Database startup and recovery
      6. Management of in-memory objects
        1. Dynamic management objects
      7. Extended Events
      8. Perfmon counters
        1. Assistance in migrating to In-memory OLTP
      9. Summary
    19. 12. In-Memory OLTP Improvements in SQL Server 2016
      1. Ch-Ch-Changes
        1. Feature improvements
          1. Collations
          2. Data types and types of data
          3. What's new with indexes?
          4. Unconstrained integrity
          5. Not all operators are created equal
          6. Size is everything!
          7. Improvements in the In-Memory OLTP Engine
          8. Down the index rabbit-hole
          9. Large object support
          10. Storage differences of on-row and off-row data
        2. Cross-feature support
          1. Security
          2. Programmability
          3. High availability
          4. Tools and wizards
      2. Summary
    20. 13. Supporting R in SQL Server
      1. Introducing R
        1. Starting with R
        2. R language Basics
      2. Manipulating data
        1. Introducing data structures in R
        2. Getting sorted with data management
      3. Understanding the data
        1. Basic visualizations
        2. Introductory statistics
      4. SQL Server R services
        1. Discovering SQL Server R services
        2. Creating scalable solutions
        3. Deploying R models
      5. Summary
    21. 14. Data Exploration and Predictive Modeling with R in SQL Server
      1. Intermediate statistics - associations
        1. Exploring discrete variables
        2. Finding associations between continuous variables
        3. Continuous and discrete variables
        4. Getting deeper into linear regression
      2. Advanced analysis - undirected methods
        1. Principal components and exploratory factor analysis
        2. Finding groups with clustering
      3. Advanced analysis - directed methods
        1. Predicting with logistic regression
        2. Classifying and predicting with decision trees
      4. Advanced graphing
        1. Introducing ggplot2
        2. Advanced graphs with ggplot2
      5. Summary

Product information

  • Title: SQL Server 2016 Developer's Guide
  • Author(s): Dejan Sarka, Miloš Radivojević, William Durkin
  • Release date: March 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781786465344