Realdolmen Education

Details

Advanced Querying Microsoft SQL Server

Deze cursus is momenteel niet ingepland op de open kalender, maar kan op aanvraag georganiseerd worden.

Cursus aanvragen

Aantal dagen

2 day(s)

Audience

This course is intended for Database Administrators, Database Developers, and Business Intelligence professionals. The course will very likely be well attended by SQL power users who aren’t necessarily database-focused or plan on taking the exam; namely, report writers, business analysts and client application developers.

Prerequisites

Before attending this course, students must have a basic knowledge of relational databases and a basic knowledge of the Microsoft Windows operating system and its core functionality. Students must have followed, or have the knowlegde - of the training Basic Querying Microsoft SQL Server 2012.

Objectives

This course provides students with the technical skills required to write advanced Transact-SQL queries for Microsoft SQL Server 2012. This course is the foundation for all SQL Server-related disciplines; namely, Database Administration, Database Development and Business Intelligence. This course helps people prepare for exam 70-461.

Methods

Instructor led training alternated with demos and exercises. Each student disposes of a workstation. All the labs for this course can be performed using the provided virtual machines.

Description

After completing this course, students will be able to:Work on the SQL Azure platform, Work with different SQL Server Datatypes, Execute stored procedures, Use table expressions, Use Pivoting and Grouping Sets, Use window ranking, offset and aggregate functions, Query SQL

Contents

.

Module 1: Working with SQL Server Data Types

This module introduces the data types SQL Server uses to store data.

Lessons

  • Introducing SQL Server Data Types
  • Working with Character Data
  • Working with Date and Time Data

Lab : Working with SQL Server Data Types

  • Writing Queries that Return Date and Time Data
  • Writing Queries that use Date and Time Functions
  • Writing Queries That Return Character Data
  • Writing Queries That Return Character Functions

After completing this module, you will be able to:

  • Explore many of the data types SQL Server uses to store data and how data types are converted between types
  • Explain the SQL Server character-based data types, how character comparisons work, and some common functions you may find useful in your queries
  • Describe data types that are used to store temporal data, how to enter dates and times so they will be properly parsed by SQL Server, and how to manipulate dates and times with built-in functions.

Module 2: Using Subqueries

This module describes several types of subquery and how and when to use them.

Lessons

  • Writing Self-Contained Subqueries
  • Writing Correlated Subqueries
  • Using the EXISTS Predicate with Subqueries

Lab : Using Subqueries

  • Writing Queries That Use Self-Contained Subqueries
  • Writing Queries That Use Scalar and Multi-Result Subqueries
  • Writing Queries That Use Correlated Subqueries and an EXISTS Clause

After completing this module, you will be able to:

  • Describe where subqueries may be used in a SELECT statement.
  • Write queries that use correlated subqueries in a SELECT statement
  • Write queries that use EXISTS predicates in a WHERE clause to test for the existence of qualifying rows
  • Use the EXISTS predicate to efficiently check for theexistence of rows in a subquery.

Module 3: Using Table Expressions

Previously in this course, you learned about using subqueries as an expression that returned results to an outer calling query. Like subqueries, table expressions are query expressions, but table expressions extend this idea by allowing you to name them and to work with their results as you would work with data in any valid relational table. Microsoft SQL Server supports four types of table expressions: derived tables, common table expression (CTEs), views, and inline table-valued functions (TVFs). In this module, you will learn to work with these forms of table expressions and learn how to use them to help create a modular approach to writing queries.

Lessons

  • Using Views
  • Using Inline Table-Valued Functions
  • Using Derived Tables
  • Using Common Table Expressions

Lab : Using Table Expressions

  • Writing Queries That Use Views
  • Writing Queries That Use Derived Tables
  • Writing Queries That Use Common Table Expressions (CTEs)
  • Writing Queries That Use Inline Table-Valued Expressions (TVFs)

After completing this module, you will be able to:

  • Write queries that return results from views.
  • Use the CREATE FUNCTION statement to create simple inline TVFs.
  • Write queries that create and retrieve results from derived tables.
  • Write queries that create CTEs and return results from the table expression.

Module 4: Using Windows Ranking, Offset, and Aggregate Functions

This module describes the benefits to using window functions. Restrict window functions to rows defined in an OVER clause, including partitions and frames. Write queries that use window functions to operate on a window of rows and return ranking, aggregation, and offset comparison results.

Lessons

  • Creating Windows with OVER
  • Exploring Window Functions

Lab : Using Windows Ranking, Offset, and Aggregate Functions

  • Writing Queries that use Ranking Functions
  • Writing Queries that use Offset Functions
  • Writing Queries that use Window Aggregate Functions

After completing this module, students will be able to:

  • Describe the T-SQL components used to define windows, and the relationships between them.
  • Write queries that use the OVER clause, with partitioning, ordering, and framing to define windows
  • Write queries that use window aggregate functions.
  • Write queries that use window ranking functions.
  • Write queries that use window offset functions

Module 5: Pivoting and Grouping Sets

This module describes write queries that pivot and unpivot result sets. Write queries that specify multiple groupings with grouping sets

Lessons

  • Writing Queries with PIVOT and UNPIVOT
  • Working with Grouping Sets

Lab : Pivoting and Grouping Sets

  • Writing Queries that use the PIVOT Operator
  • Writing Queries that use the UNPIVOT Operator
  • Writing Queries that use the GROUPING SETS CUBE and ROLLUP Subclauses

After completing this module, students will be able to:

  • Describe how pivoting data can be used in T-SQL queries.
  • Write queries that pivot data from rows to columns using the PIVOT operator.
  • Write queries that unpivot data from columns back to rows using the UNPIVOT operator.
  • Write queries using the GROUPING SETS subclause.
  • Write queries that use ROLLUP AND CUBE.
  • Write queries that use the GROUPING_ID function.

Module 6: Executing Stored Procedures

This module describes how to return results by executing stored procedures. Pass parameters to procedures. Create simple stored procedures that encapsulate a SELECT statement. Construct and execute dynamic SQL with EXEC and sp_executesql.

Lessons

  • Querying Data with Stored Procedures
  • Passing Parameters to Stored procedures
  • Creating Simple Stored Procedures
  • Working with Dynamic SQL

Lab : Executing Stored Procedures

  • Using the EXECUTE statement to Invoke Stored Procedures
  • Passing Parameters to Stored procedures
  • Executing System Stored Procedures

After completing this module, students will be able to:

  • Describe stored procedures and their use.
  • Write T-SQL statements that execute stored procedures to return data.
  • Write EXECUTE statements that pass input parameters to stored procedures.
  • Write T-SQL batches that prepare output parameters and execute stored procedures.
  • Use the CREATE PROCEDURE statement to write a stored procedure.
  • Create a stored procedure that accepts input parameters.
  • Describe how T-SQL can be dynamically constructed.
  • Write queries that use dynamic SQL.

Module 7: Programming with T-SQL

This module describes how to enhance your T-SQL code with programming elements.

Lessons

  • T-SQL Programming Elements
  • Controlling Program Flow

Lab : Programming with T-SQL

  • Declaring Variables and Delimiting Batches
  • Using Control-Of-Flow Elements
  • Using Variables in a Dynamic SQL Statement
  • Using Synonyms

After completing this module, students will be able to:

  • Describe how Microsoft SQL Server treats collections of statements as batches.
  • Create and submit batches of T-SQL code for execution by SQL Server.
  • Describe how SQL Server stores temporary objects as variables.
  • Write code that declares and assigns variables.
  • Create and invoke synonyms
  • Describe the control-of-flow elements in T-SQL.
  • Write T-SQL code using IF...ELSE blocks.
  • Write T-SQL code that uses WHILE.

Module 8: Implementing Error Handling

This module introduces error handling for T-SQL.

Lessons

  • Implementing T-SQL error handling
  • Implementing structured exception handling

Lab : Implementing Error Handling

  • Redirecting errors with TRY/CATCH
  • Using THROW to pass an error message back to a client

After completing this module, students will be able to:

  • Implement T-SQL error handling.
  • Implement structured exception handling.