Solved

Index Details Of a Table in SQL Server

Posted on 2004-09-10
2
6,871 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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 …
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
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now