I am exploring a legacy database system and have very little knowledge of its internals. I would like to find all the stored procedures that invoke another stored procedure A
.
How best to do this?
Can I write something like this pseudocode:
select name from AllStoredProcedures as Asp where Asp.TextualContent contains 'A'
Asp.TextualContent
means the actual SQL contained in the SP.
Expand Databases, expand the database in which the procedure belongs, and then expand Programmability. Expand Stored Procedures, right-click the procedure and then select Script Stored Procedure as, and then select one of the following: Create To, Alter To, or Drop and Create To. Select New Query Editor Window.
SELECT OBJECT_NAME(object_id), definition FROM sys.sql_modules WHERE objectproperty(object_id,'IsProcedure') = 1 AND definition like '%Foo%'
For SQL Server 2005/2008:
SELECT s.name SchemaName ,o.name RoutineName ,o.[type] RoutineType ,procs.* FROM sys.sql_modules procs INNER JOIN sys.objects o ON procs.object_id = o.object_id INNER JOIN sys.schemas s ON o.schema_id = s.schema_id WHERE procs.[definition] LIKE '%A%' --AND o.[type] = 'P' --'P' for stored procedures
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With