What Do You Use CTEs for?

Download PDF

There are many great reasons to use Common Expressions, from derived table query re-use, to doing recursive queries and creating hierarchies to doing data paging, cleaner code, or de-duplication of data.

I am curious what you are using CTE’s for?

Please post a reply with the top things you use CTE’s for.


Tagged with: ,
3 comments on “What Do You Use CTEs for?
  1. Mbourgon says:

    Mostly cleaner queries and dumping temp/sub/derived tables, but also with paging and recursion.

  2. Mally says:


    Can CTE’s be used instead of while loops or cursors? Please advise.


    • SteveStedman SteveStedman says:

      Yes, there are many cases where a CTE can be used to accomplish the same thing as a loop or cursor. There are however some cases where a cursor is a better option, however there are not many.

Leave a Reply

Your email address will not be published. Required fields are marked *


Time limit is exhausted. Please reload CAPTCHA.