One problem with the script is that it is hard coded to use db_id 70 when using this:
sys.dm_db_index_physical_stats (70, NULL, NULL, NULL, NULL) AS p
Maybe change that to Default, null or 0 instead of 70
Sue
DB_ID() would probably be more efficient, since dm_db_index_usage_stats is scoped to the current DB.
I referenced this: sys.dm_db_index_physical_stats (70, NULL, NULL, NULL, NULL)
With dm_db_index_physical_stats, specifying default, null or 0 uses the current database.
Sue