Relative Content

Tag Archive for sqlt-sqlhierarchical-datarecursive-cte

Keeping a constant identifying value at the beginning of a recursively unioning cte

As part of a TSQL project on a Microsoft SQL Server, I’m using a recursively unioning cte to trace a series of child parent relationships through some hierarchical data to pull each individual element into a row that I can then pivot into a single row. As an example, my recursively unioning cte would turn the following rows from A to B for one of the HCC values. C would be the desired outcome after the pivot.