• I ran into two errors on my largest database. Both were easy to remedy.

    The first was simply that I had some object names in excess of your 50 character limit. I changed the two varchar parameters from 50 to 60 and eliminated the error.

    The second was a collation conflict in the join. I modified the join as follows:

    join ##tmp2 on ##tmp.nam COLLATE Latin1_General_CI_AS = ##tmp2.TableName

    Great script. Thanks for posting!