From the course: Microsoft SQL Server 2016: Query Data
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Introducing common table expressions - SQL Server Tutorial
From the course: Microsoft SQL Server 2016: Query Data
Introducing common table expressions
- [Instructor] In this lesson, we're going to take a look at the concept of Common Table Expressions. They're also commonly known as CTEs. A CTE, really, is a temporary table that exists only within the scope of some executing DML statement, such as a select, an insert, or an update. The CTE only lasts for the duration of the query, which means it exists in memory only, and not in the database as an object that you could reference later. CTEs do have the ability to reference themselves in a query, and you'll find the common uses for CTEs such as creating recursive queries, in other words, the query is calling itself, it can be a temporary view, in the event that you don't want to create or store a view in your database. They can also reference the result set multiple times in the same statement. Typically, you'll find them used to simplify complex queries by allowing you to divide the complexity into smaller segments that are easier to understand and write. CTEs can also exist in…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.