• Maybe I'm reading it wrong, but short of going into CLR (which I personally try to avoid for maintainability) CTE dosen't seem to be much slower?

    I mostly liked the link I provided for it's simplicity, but then again I'm not in need of break neck speeds, my script will only be running about once per day when noone else is logged in, so a couple of extra milliseconds wont matter 😉