Wednesday 28 December 2011

Common Table Expressions

Microsoft offers the following four advantages of CTEs:

  • Create a recursive query.

  • Substitute for a view when the general use of a view is not required; that is, you do not have to store the definition in metadata.

  • Enable grouping by a column that is derived from a scalar sub select, or a function that is either not deterministic or has external access.

  • Reference the resulting table multiple times in the same statement.

Using a CTE offers the advantages of improved readability and ease in maintenance of complex queries. The query can be divided into separate, simple, logical building blocks. These simple blocks can then be used to build more complex, interim CTEs until the final result set is generated. 


  • About are as follow


A common table expression (CTE) can be thought of as a temporary result set that is defined 

No comments:

Post a Comment