C
C
Che132016-08-22 09:44:58
SQL
Che13, 2016-08-22 09:44:58

SQL What databases are used?

There is MS SQL Server 2005 on Windows Server 2003 R2, which is practically not used.
It is necessary to understand which databases are used and which are not.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Filatov, 2016-08-22
@NYMEZIDE

see logs

E
Edward, 2016-08-23
@edb

there are statistics on the use of each index, including the clustered one.
this query must be executed in the context of each database. But this won't work for heap tables without indexes.

SELECT
    OBJECT_NAME(i.object_id) AS [Table Name]
    , i.name AS [Index Name]
    , i.is_disabled
    , s.last_user_update AS [Last Update Time]
    , s.user_updates AS [Updates]
    , user_scans
    , user_seeks
    , user_lookups
    , last_user_scan
    , last_user_seek
    , last_user_lookup
FROM     sys.dm_db_index_usage_stats AS s
   JOIN     sys.indexes AS i ON       i.object_id = s.object_id AND      i.index_id = s.index_id
   JOIN     sys.objects AS o ON       o.object_id = s.object_id
WHERE    s.database_id = DB_ID()
AND      OBJECTPROPERTY(i.[object_id],         'IsSystemTable'   ) = 0
AND      INDEXPROPERTY (i.[object_id], i.name, 'IsAutoStatistics') = 0
AND      INDEXPROPERTY (i.[object_id], i.name, 'IsHypothetical'  ) = 0
AND      INDEXPROPERTY (i.[object_id], i.name, 'IsStatistics'    ) = 0
AND      INDEXPROPERTY (i.[object_id], i.name, 'IsFulltextKey'   ) = 0
AND      o.type <> 'IT'
AND i.object_id = object_id('TABLE_NAME')
ORDER BY OBJECT_NAME(i.object_id)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question