What is the use of common table expression (CTE) in Sql Server?

  • CTEs are used to make the query easier.
  • Whenever there are too many joins are being used in a query then we can use CTEs to make it simple.

Example

With test
AS
(
 SELECT col1,col2
 FROM table
)
SELECT * FROM test

Leave a Reply