In last month's article, I covered the new APPLY operator, Ranking functions, and the new TRY...CATCH capabilties in T-SQL 2005. This month I'll talk about two of the largest enhancements in the SQL 2005 language - Common Table Expressions (CTEs) and Recursive Queries.
Both fo these are part of the SQL-99 standard. CTEs allow developers to more expressively identify a temporary result set (similar to a derived table or temporary view). Recursive Queries allow developers to more easily query hierarchies of data, by permitting developers (in a single SQL statement) to recursively query into a CTE that's also being populated).
CTEs and Recursive queries can be a little difficult to initially grasp, so I'm going to show several code examples to demonstrate their value.