Solved

Index Details Of a Table in SQL Server

Posted on 2004-09-10
2
6,891 Views
Last Modified: 2008-01-09
If i want to see the Index deatils for a given table say 'ABC' how can i do it? I need

INDEX_NAME, COLUMN_NAME, TABLE_NAME, INDEX_TYPE columns for
       In oracle i am able to find it out from the query mentioned below,
   select B.INDEX_NAME, B.COLUMN_NAME, B.TABLE_NAME, A.INDEX_TYPE from USER_INDEXES A,

USER_IND_COLUMNS B
where B.TABLE_NAME = 'ABC' AND A.INDEX_NAME = B.INDEX_NAME
order by 3;


Please tell me how to do it in SQL Server? My mail ID is, kama_biet@rediffmail.com


Regards...
Sujit
0
Comment
Question by:sujit_kumar
2 Comments
 
LVL 10

Accepted Solution

by:
AustinSeven earned 50 total points
ID: 12025807
sp_helpindex 'tablename'

AustinSeven
0
 
LVL 11

Author Comment

by:sujit_kumar
ID: 12065068
Here is the answer,

SELECT  CAST(SO.[name] AS CHAR(20)) AS TableName
      , CAST(SI.[name] AS CHAR(30)) AS IndexName
      , CAST(SC.[name] AS CHAR(15)) AS ColName
      , CAST(ST.[name] AS CHAR(10)) AS TypeVal
      , CASE WHEN (SI.status & 16)<>0 THEN 'Yes' ELSE 'No' END AS ClusteredIndex
FROM
      SYSOBJECTS SO INNER JOIN SYSINDEXES SI INNER JOIN SYSINDEXKEYS SIK
      ON SIK.[id] = SI.[id]
      AND SIK.indid = SI.indid INNER JOIN SYSCOLUMNS SC INNER JOIN SYSTYPES ST
    ON SC.xtype = ST.xtype ON SIK.[id] = SC.[id]
      AND SIK.colid = SC.colid
      ON SO.[id] = SI.[id]
WHERE SO.xtype = 'u'
AND SI.indid > 0
AND      SI.indid < 255
AND      (SI.status & 64)=0
ORDER BY
      TableName
      , IndexName
      , SIK.keyno

Regards....
Sujit
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question