• Another note.

    Even if that one data line is bad, I don't think the CTE will work because you're using VARCHAR for the ChildID and ParentID. In such a case, they really aren't ID fields, therefore are pretty much uncomparable. In character fields, A will always come before H, and special characters have their own ANSI codes which will cause them to filter oddly in SQL Server.

    Can you give us more appropriate sample data (not using Lowell's but using information that is more like what your table contains) and a more appropriate table DDL?

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.