Explain Common Table Expression(CTE) in SQL Server

 Posted by CGN007 on 7/20/2012 | Category: Sql Server Interview questions | Views: 3392 | Points: 40

The common table expression (CTE) is a temporary named result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement.
A CTE is defined with two parts:

A WITH clause containing a SELECT statement that generates a valid table
An outer SELECT statement that references the table expression.

The basic syntax structure for a CTE is:

WITH expression_name [ ( column_name [,...n] ) ] 

( CTE_query_definition )

SELECT <column_list> FROM expression_name;

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Sqldev on: 3/11/2013 | Points: 10

Below video have complete information about CTE like what is CTE , properties of CTE and examples for CTE in sql server.


Best Regards,
Sql Expert

Login to post response