3

I am trying to figure out how specific table is loaded in Microsoft SQL Server Management Studio. Is there a way to search through all the Stored Procedure queries? I can chose to modify each one and search through the query but there are too many to manually search in that fashion. Any advice in relation to searching for strings in SQL Server Management Studio would be much appreciated. thanks

3 Answers 3

9
SELECT OBJECT_NAME(M.object_id), M.*
FROM sys.sql_modules M
JOIN sys.procedures P
ON M.object_id = P.object_id
WHERE M.definition LIKE '%YourTable%'
Sign up to request clarification or add additional context in comments.

4 Comments

This may be working... Do you know how to match the object_id to a specific stored procedure?
@tylercomp - I added the name to my answer
Awesome, do you know how to match object type as well?
@tylercomp - Added a JOIN that shows you only the stored procedures.
3

Have a look at the FREE Red-Gate tool called SQL Search which does this - it searches your entire database for any kind of string(s).

enter image description here

enter image description here

It's a great must-have tool for any DBA or database developer - did I already mention it's absolutely FREE to use for any kind of use??

6 Comments

Seems nice, how light is the install?
@Marc_s - but what is the PRICE?
@JNK no such thing as a free lunch?
@tylercomp: two files, less than 20K together - light enough?
@tylercomp - I'm just giving marc a hard time.
|
-1

From here, I found the following snippet to search through the stored procs:

exec sp_stored_procedures 'a%'
OR
exec sp_stored_procedures @sp_name = 'a%'

1 Comment

hmmm, looks like that only returns the names... I am wanting to search the queries for these procedures...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.