Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Index Details Of a Table in SQL Server

Posted on 2004-09-10
2
Medium Priority
?
6,956 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 150 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

916 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