• The indentation uses some weird characters. In my case I pasted it into an advanced text editor and they came up with question marks. I just replaced the question marks with spaces and it worked great.

    Also, if you want to run this in MSSQL 2000, replace the table variable with a temporary table (ie. @dbcctab becomes #dbcctab)