• If you provide the DDL (CREATE TABLE statement(s)) for the table(s) involved, sample data (as a series of INSERT INTO statements) for the table(s), expected results based on sample the sample data you may be surprised to find a better way of accomplishing what you are attempting to do with what appears to be a recursive CTE which won't scale well at all.