Features and Limitations of Common Table Expressions in Azure

The current implementation of CTEs in Azure Synapse Analytics and Analytics Platform System (PDW) has the following features and limitations:

  1. A CTE can be only specified in a SELECT statement.
  2.  A CTE can be only specified in a CREATE VIEW statement.
  3. A CTE can be only specified in a CREATE TABLE AS SELECT (CTAS) statement.
  4. A CTE can be only specified in a CREATE REMOTE TABLE AS SELECT (CRTAS) statement.
  5. A CTE can be only specified in a CREATE EXTERNAL TABLE AS SELECT (CETAS) statement.


CTE in SQL

The Common Table Expressions (CTE) were introduced into standard SQL in order to simplify various classes of SQL Queries for which a derived table was just unsuitable. CTE was introduced in SQL Server 2005, the common table expression (CTE) is a temporary named result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement. You can also use a CTE in a CREATE view, as part of the view’s SELECT query. In addition, as of SQL Server 2008, you can add a CTE to the new MERGE statement. 

Similar Reads

Why do We Need CTE in the SQL server?

A common table [deprecated]CTE is a powerful SQL construct that helps simplify queries. CTEs act as virtual tables (with records and columns) that are created during query execution, used by the query, and deleted after the query executes....

Using the CTE

We can define CTEs by adding a WITH clause directly before the SELECT, INSERT, UPDATE, DELETE, or MERGE statement. The WITH clause can include one or more CTEs separated by commas....

Rules for Define and Use of Recursive Common Table Expressions

The following guidelines apply to defining recursive common table expressions:...

Creating a Recursive Common Table Expression

A recursive CTE is one that references itself within that CTE. The recursive CTE is useful when working with hierarchical data as the CTE continues to execute until the query returns the entire hierarchy....

Features and Limitations of Common Table Expressions in Azure

The current implementation of CTEs in Azure Synapse Analytics and Analytics Platform System (PDW) has the following features and limitations:...