Click here to Skip to main content
11,578,739 members (62,944 online)
Click here to Skip to main content

SQL Server Scripts: Get All Nested Stored Procedures List (Procedures with Dependent Procedures)

, 1 Nov 2012 CPOL 11.8K 3
Rate this:
Please Sign up or sign in to vote.
A stored procedure can be called from another stored procedure as nested stored procedure. How to get a list of these stored procedures with their nested one


A stored procedure can be called from another stored procedure as a nested stored procedure. Recently on production server, we were asked for all stored procedures in which other stored procedures are called as nested. Here is a simple script.

Using the Code

FROM    sysdepends
        INNER JOIN sys.objects OBJ ON sysdepends.ID = OBJ.OBJECT_ID
        INNER JOIN sys.objects OBJDEP ON sysdepends.DEPID = OBJDEP.OBJECT_ID
WHERE obj.type = 'P'
AND Objdep.type = 'P'
AND = procs.object_id

), 2, 8000) AS NestedProcedures
FROM sys.procedures  procs )InnerTab
WHERE NestedProcedures IS NOT NULL


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

aasim abdullah
Team Leader CureMD
Pakistan Pakistan
Aasim Abdullah is working as SQL Server DBA with CureMD ( based in NY, USA. He has been working with SQL Server since 2007 (Version 2005) and has used it in many projects as a developer, administrator, database designer. Aasim's primary interest is SQL Server performance tuning. If he finds the time, he like to sketch faces with graphite pencils.

You may also be interested in...

Comments and Discussions

Questionhow do you get the SP under different schema Pin
shweta nikhil mishra29-Oct-14 4:36
professionalshweta nikhil mishra29-Oct-14 4:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150603.1 | Last Updated 1 Nov 2012
Article Copyright 2012 by aasim abdullah
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid