Querying Data with Transact-SQL

Session Detail:    Classroom, Virtual 5 Day

This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students requiring the knowledge for other courses in the SQL Server curriculum. Days 4 & 5 teach the remaining skills required to take exam 70-761

Prerequisites

  • Basic knowledge of the Microsoft Windows operating system and its core functionality.
  • Working knowledge of relational databases.

Who Can Benefit

The main purpose of the course is to give students a good understanding of the Transact-SQL language which is used by all SQL Server-related disciplines; namely, Database Administration, Database Development, and BusinessIntelligence. As such, the primary target audience for this course is DatabaseAdministrators, Database Developers, and BI professionals.

Session Outline

Class Outline

Module 1: Introduction to Microsoft SQL Server

  • Lesson 1: The Basic Architecture of SQL Server
  • Lesson 2: SQL Server Editions and Versions
  • Lesson 3: Getting Started with SQL Server Management Studio

After completing this module, you will be able to:

  • Describe relational databases and Transact-SQL queries
  • Describe the on-premise and cloud-based editions and versions of SQL Server
  • Describe how to use SQL Server Management Studio (SSMS) to connect to an instance of SQL Server, explore the databases contained in the instance, and work with script files that contain T-SQL queries

Module 2: Introduction to T-SQL Querying

  • Lesson 1: Introducing T-SQL
  • Lesson 2: Understanding Sets
  • Lesson 3: Understanding Predicate Logic
  • Lesson 4: Understanding the Logical Order of Operations in SELECT statements

After completing this module, you will be able to:

  • Describe the role of T-SQL in writing SELECT statements
  • Describe the elements of the T-SQL language and which elements will be useful in writing queries
  • Describe the concepts of the set theory, one of the mathematical underpinnings of relational databases, and to help you apply it to how you think about querying SQL Server
  • Describe predicate logic and examine its application to querying SQL Server
  • Explain the elements of a SELECT statement, delineate the order in which the elements are evaluated, and then apply this understanding to a practical approach to writing queries

Module 3: Writing SELECT Queries

  • Lesson 1: Writing Simple SELECT Statements
  • Lesson 2: Eliminating Duplicates with DISTINCT
  • Lesson 3: Using Column and Table Aliases
  • Lesson 4: Writing Simple CASE Expressions

After completing this module, you will be able to:

  • Describe the structure and format of the SELECT statement, as well as enhancements that will add functionality and readability to your queries
  • Describe how to eliminate duplicates using the DISTINCT clause
  • Describe the use of column and table aliases
  • Understand and use CASE expressions

Module 4: Querying Multiple Tables

  • Lesson 1: Understanding Joins
  • Lesson 2: Querying with Inner Joins
  • Lesson 3: Querying with Outer Joins
  • Lesson 4: Querying with Cross Joins and Self Joins

After completing this module, you will be able to:

  • Explain the fundamentals of joins in SQL Server
  • Write inner join queries
  • Write queries that use outer joins
  • Use additional join types

Module 5: Sorting and Filtering Data

  • Lesson 1: Sorting Data
  • Lesson 2: Filtering Data with Predicates
  • Lesson 3: Filtering Data with TOP and OFFSET-FETCH
  • Lesson 4: Working with Unknown Values

After completing this module, you will be able to:

  • Explain how to add an ORDER BY clause to your queries to control the order of rows displayed in your query’s output
  • Explain how to construct WHERE clauses to filter out rows that do not match the predicate
  • Explain how to limit ranges of rows in the SELECT clause using a TOP option
  • Explain how to limit ranges of rows using the OFFSET-FETCH option of an ORDER BY clause
  • Explain how three-valued logic accounts for unknown and missing values, how SQL Server uses NULL to mark missing values, and how to test for NULL in your queries

Module 6: Working with SQL Server Data Types

  • Lesson 1: Introducing SQL Server Data Types
  • Lesson 2: Working with Character Data
  • Lesson 3: Working with Date and Time Data

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 7: Using DML to Modify Data

  • Lesson 1: Adding Data to Tables
  • Lesson 2: Modifying and Removing Data
  • Lesson 3: Generating automatic column values

After completing this module, you will be able to:

  • Use INSERT and SELECT INTO statements
  • Use UPDATE, MERGE, DELETE, and TRUNCATE

Module 8: Using Built-In Functions

  • Lesson 1: Writing Queries with Built-In Functions
  • Lesson 2: Using Conversion Functions
  • Lesson 3: Using Logical Functions
  • Lesson 4: Using Functions to Work with NULL

After completing this module, you will be able to:

  • Describe the types of functions provided by SQL Server, and then focus on working with scalar functions
  • Explain how to explicitly convert data between types using several SQL Server functions
  • Describe how to use logical functions that evaluate an expression and return a scalar result
  • Describe additional functions for working with NULL

Module 9: Grouping and Aggregating Data

  • Lesson 1: Using Aggregate Functions
  • Lesson 2: Using the GROUP BY Clause
  • Lesson 3: Filtering Groups with HAVING

After completing this module, you will be able to:

  • Describe the built-in aggregate function in SQL Server and write queries using it
  • Write queries that separate rows using the GROUP BY clause
  • Write queries that use the HAVING clause to filter groups

Module 10: Using Subqueries

  • Lesson 1: Writing Self-Contained Subqueries
  • Lesson 2: Writing Correlated Subqueries
  • Lesson 3: Using the EXISTS Predicate with Subqueries

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 the existence of rows in a subquery

Module 11: Using Table Expressions

  • Lesson 1: Using Views
  • Lesson 2: Using Inline Table-Valued Functions
  • Lesson 3: Using Derived Tables
  • Lesson 4: Using Common Table Expressions

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 12: Using Set Operators

 

  • Lesson 1: Writing Queries with the UNION operator
  • Lesson 2: Using EXCEPT and INTERSECT
  • Lesson 3: Using APPLY

After completing this module, students will be able to:

  • Write queries that use UNION to combine input sets
  • Write queries that use UNION ALL to combine input sets
  • Write queries that use the EXCEPT operator to return only rows in one set but not another
  • Write queries that use the INTERSECT operator to return only rows that are present in both sets
  • Write queries using the CROSS APPLY operator
  • Write queries using the OUTER APPLY operator

 

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

  • Lesson 1: Creating Windows with OVER
  • Lesson 2: Exploring Window 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 14: Pivoting and Grouping Sets

  • Lesson 1: Writing Queries with PIVOT and UNPIVOT
  • Lesson 2: Working with Grouping Sets

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 15: Executing Stored Procedures

  • Lesson 1: Querying Data with Stored Procedures
  • Lesson 2: Passing Parameters to Stored procedures
  • Lesson 3: Creating Simple Stored Procedures
  • Lesson 4: Working with Dynamic SQL

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 16: Programming with T-SQL

  • Lesson 1: T-SQL Programming Elements
  • Lesson 2: Controlling Program Flow

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 17: Implementing Error Handling

  • Lesson 1: Implementing T-SQL error handling
  • Lesson 2: Implementing structured exception handling

After completing this module, students will be able to:

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

Module 18: Implementing Transactions

  • Lesson 1: Transactions and the database engines
  • Lesson 2: Controlling transactions

After completing this module, students will be able to:

  • Describe transactions and the differences between batches and transactions
  • Describe batches and how they are handled by SQL Server
  • Create and manage transactions with transaction control language (TCL) statements
  • Use SET XACT_ABORT to define SQL Servers handling of transactions outside TRY/CATCH blocks

Need to train your team?

All of our sessions can be customized to meet your team’s specific need. Build the perfect program by picking and choosing topics from any of the courses in our catalog. A personalized private session gives you the ultimate flexibility and helps maximize your team’s valuable time!

Requesting Team Training
DateTimeTypePriceAdd To Cart

Querying Data with Transact-SQL

5 Day
Classroom, Virtual

$3,095.00

Chat with a Coach

Chat with a Coach

Have a more immediate need? Why spend the next hour searching online for answers when you can spend just 15 minutes with one of our experts and get accurate and personalized answers to all of your questions. 

$9.99 | 15 Minutes

Book Now