Query to retrieve tables indexed in a specific database

Can someone provide me a query in sql server to retrieve tables that were made for indexing for a specific database ....

+3
source share
3 answers

Your question is somewhat unclear. This will return all tables with at least one index.

select DISTINCT OBJECT_NAME(object_id)  
from sys.indexes 
where type<>0

Or for SQL Server 2000

select DISTINCT OBJECT_NAME(id)   
from sysindexes 
where indid<>0
+3
source
select object_name(object_id),* from sys.indexes where type <> 0

This will return you all the indexes available in your database. But be careful, it also lists system tables.

+2
source

sys.indexes DMV , :

SELECT TableName = object_name(Object_Id)
     , IndexName = Name
     , IndexType = Type_Desc

 FROM sys.indexes

Type_Desc , , .

sys.tables :

SELECT TableName = st.Name
     , IndexName = si.name
     , IndexType = si.type_desc
  FROM SYS.indexes si
  JOIN SYS.tables st
    ON si.object_id  = st.object_id
+1

Source: https://habr.com/ru/post/1778309/


All Articles