Hi,
firstly if this is in the wrong sub-forum sorry and if someone could move it that would be fantastic...
Issue
I need to change numereous tables in a number of databases so I obviously need to be sure that I ammend all dependant objects.
I have used sys.dm_sql_referencing_entities and that works fine when, for example, the view is in that same database as the table - when it is not I have a problem.
So
USE [database-a]
SELECT referencing_schema_name, referencing_entity_name, referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('myscheme.mytable', 'OBJECT');
GO
Returns all the objects referencing mytable in database-a but I am stuck when for example the view is in database-b
USE [database-b]
SELECT referencing_schema_name, referencing_entity_name, referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('myscheme.mytable', 'OBJECT');
GO
does not find the view, however
SELECT OBJECT_SCHEMA_NAME(object_id), OBJECT_NAME(object_id) FROM sys.sql_modules WHERE [definition] LIKE '%mytable%'
does.
Question
1. Is there an easy way of finding all the stored procedures and views that reference my tables regardless of the database the view or stored procedure resides?
I can knock up a script that switches database and runs the select from sys.sql_modules for every database but that seems
clumsy at best.
2. I have not looked into this yet so sorry if it is obvious - but I also need to know which SSIS packages reference the tables I am about to change...
Before you ask
I did not create these views / stored procedures / SSIS packages and documentation is lacking (read missing).
I will not be creating any views in different databases from the table they reference - excluding cross database views where this is justified.
Thanks in advance.
Shaun