What Do You Use CTEs for?
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.
Thanks!!
More from Stedman Solutions:
Steve and the team at Stedman Solutions are here for all your SQL Server needs.
Contact us today for your free 30 minute consultation..
We are ready to help!
Mostly cleaner queries and dumping temp/sub/derived tables, but also with paging and recursion.
Steve,
Can CTE’s be used instead of while loops or cursors? Please advise.
Thanks,
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.