Alberto:
This works fine, but 2 things:
1. It will not work on SQL 2005 as it does not have the sys.dm_sql_referencing_entities view
2. It will not work if the formal references have been broken (as one of the parties has been dropped/created).
So the original script, even being painfully slow, shows everything that has been coded to the stored proc definition.
Aleksey