Finding unused objects

  • Follow


Using the following DMV I get to know which of the objects in the DB is in use
dm_exec_trigger_stats, dm_exec_procedure_stats, dm_db_index_usage_stats
Is there a DMV to have this data about a View?

0
Reply Utf 9/12/2010 8:03:48 AM

Gal (Gal@discussions.microsoft.com) writes:
> Using the following DMV I get to know which of the objects in the DB is
> in use dm_exec_trigger_stats, dm_exec_procedure_stats,
> dm_db_index_usage_stats 
> Is there a DMV to have this data about a View?

If you want to know which are the unused procedures:

 SELECT o.name
 FROM   sys.objects o
 WHERE  o.type = 'P'
   AND  NOT EXISTS (SELECT *
                    FROM   sys.dm_exec_procedure_stats ps
                    WHERE  ps.database_id = db_id()
                      AND  ps.object_id = o.object_id)

But beware! Just because a procedure is not in the cache does not mean that 
it is unused. It may be a procedure used by an end-of-month report, for 
instance.

-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

0
Reply Erland 9/12/2010 9:14:41 AM


1 Replies
1069 Views

(page loaded in 0.035 seconds)

Similiar Articles:
















7/27/2012 9:12:38 PM


Reply: