Query the contents of stored procedures on SQL Server

后端 未结 4 831
时光取名叫无心
时光取名叫无心 2021-02-03 21:10

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

4条回答
  •  走了就别回头了
    2021-02-03 21:32

    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
    

提交回复
热议问题