0

Please help me on this issue. I have a specific table from a specific database. I want to find the stored procedure using the table from all databases available.

1 Answer 1

2

For this, I would use Aaron Bertrand's improved sp_msforeachdb

EXECUTE sp_foreachdb @command = N'SELECT * FROM ?.sys.sql_modules AS sm WHERE sm.Definition LIKE ''%dbo.YourTable%''' , @user_only = 1 

The @command is necessary, but I added the @user_only to show that you can skip system databases. If you do want to check them, remove this parameter.


I recommend Aaron's solution over sp_msforeachdb because it is unsupported, and as he mentions in his blog, it can miss databases under heavy load.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.