SQL Server: CTE - Common Table Expressions

A CTE is a temporary result set derived from a single SELECT, INSERT, UPDATE, DELETE or CREATE VIEW statement. The scope of the result set is with in the execution time. CTE is similar to derived tables but not physical SQL objects.

Syntax:
With CTE_Name(ColumnName1,ColumnName2,...) As
(
CTE query definition
)
SELECT ColumnList from CTE_Name

Example:

 

No comments:

Post a Comment