Explain Common Table Expression(CTE) in SQL Server

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

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] ) ] 

AS
( 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
Hi,

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

http://www.youtube.com/watch?v=Ly-YqPVdVOk&feature=youtu.be


Best Regards,
Sql Expert
http://learnsqltips.blogspot.com/

Login to post response