I want to find the reference of particular table in all the databases of the particular server.
Example :
My query window is opened for DB1 database and executed the query as:
exec sp_depends 'dbo.table1'
It return me all the references of the table table1 in the database objects like (procedures,functions, triggers) of database DB1 only but I want to know the references of the table in all other database on the same server without going to particular database query window everytime and running the query.
exec sp_depends 'dbo.table1'
I tried below statement for all databases but it did not work out:
DECLARE @command varchar(1000)
SELECT @command = 'USE ? exec sp_depends ''dbo.table1'''
EXEC sp_MSforeachdb @command