TransWikia.com

Index usage for database: where are the sys tables located

Database Administrators Asked on October 28, 2021

I have seen a couple of scripts that query some sys.someName tables to find usage of indexes in a database. My guess is that these tables are tied to a database e.g. there is a sys.indexes table in every database. But where can I see these tables in SSMS? Or are all these tables in the msdb database?

An example of a script I have found is this. Of course when I change the context of the database the result set changes also but I cannot find these tables in SSMS.

SELECT  Tab.name  Table_Name 
             ,IX.name  Index_Name
             ,IX.type_desc Index_Type
             ,Col.name  Index_Column_Name
             ,IXC.is_included_column Is_Included_Column
              
           FROM  sys.indexes IX 
           INNER JOIN sys.index_columns IXC  ON  IX.object_id   =   IXC.object_id AND  IX.index_id  =  IXC.index_id  
           INNER JOIN sys.columns Col   ON  IX.object_id   =   Col.object_id  AND IXC.column_id  =   Col.column_id     
           INNER JOIN sys.tables Tab      ON  IX.object_id = Tab.object_id

Source (https://www.sqlshack.com/gathering-sql-server-indexes-statistics-and-usage-information/)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP