SQL 2005 Enterprise Edition SP 2
Thanks in advance.
Kay
You could start by running sp_depends for each table in the database. Unfortunately sp_depends is not always 100% accurate, and it will not pick up things like inline SQL being called from applications, but it is a start.
The DMV query below can also help find unused tables.
-- Unused tables & indexes. Tables have index_id’s of either 0 = Heap table or 1 = Clustered Index
DECLARE @.dbid int
SELECT @.dbid =db_id()
SELECT objectname=object_name(i.object_id), indexname=i.name, i.index_id
FROMsys.indexes i,sys.objectsAS o
WHEREobjectproperty(o.object_id,'IsUserTable')= 1
AND i.index_id NOTIN(SELECT s.index_id
FROMsys.dm_db_index_usage_statsAS s
WHERE s.object_id=i.object_id
AND i.index_id=s.index_id
AND database_id = @.dbid )
AND o.object_id= i.object_id
ORDERBY objectname,i.index_id,indexname ASC
No comments:
Post a Comment