Question
Define Common table expression (CTE) in SQL Server
Answer
Common table expression or CTE can be described as the temporary, named record set return by the execution of the query (insert, delete, update, select or update view statement). It is not stored as an object in the database and it last only till the execution of the SQL Query.
It also can reference itself. It can be referenced multiple times.
The Common table expression has the following syntax:
With Expressionname (Column list)
AS
(
CTE query definition
)
Here, Expressionname is the name of the CTE, Column list is the name of the unique column names which are return as the record set through the execution of the CTE query and CTE query definition is the SQL query which we are going to use in the CTE.
Read More..
 
[110 clicks]
Published under:
SQL Server Interview Questions · · · ·