Hello Geeks and welcome to the Day 43 of the long series of One DMV a day. In this series of blogs I will be exploring and explaining the most useful DMVs in SQL Server. As we go ahead in this series we will also talk about the usage, linking between DMVs and some scenarios where these DMVs will be helpful while you are using SQL Server. For the complete list in the series please click here.

Today I will be covering sys.dm_exec_cached_plan_dependent_objects. This DMF gives you the information about dependent objects on the current plan. You need to pass the valid plan_handle and get the dependent objects.

Sys.dm_exec_cached_plan_dependent_objects is mapped to sys.dm_os_memory_objects on memory_object_address. This will help you get to the memory object associated with every plan in the cache.

Let us get the details from sys.dm_exec_cached_plan_dependent_objects. I will create procedure to use a cursor and fetch only one row from a table. This way I will have the procedure itself and the cursor as objects for the plan.

Now execute the procedure at least once and run the below query to get the plan handle.


Pass the plan handle to sys.dm_exec_cached_plan_dependent_objects to see the dependent objects.


In the output you can see that it has displayed two objects. The compiled Plan is related to the plan of the procedure. The cursor is related to the cursor inside the procedure. The objects like CLR also are shown when used in sys.dm_exec_cached_plan_dependent_objects.

Tomorrow I will be covering another execution related DMV. Stay tuned. Till then

Happy Learning,

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook |
Follow me on Twitter | Follow me on FaceBook