• thanks for the script. Note to people using it, the CTE doesn't deal with tables from other databases.