advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Average Rating: 3.5/5 | Rate this item | 18 users have rated this item.
Expertise: Beginner
Language: SQL
August 23, 2005
Retrieve All the Index Names for a Given Table Using SQL Query
Use this code to retrieve all the Index names for a given table Using SQL query:

declare @tblName varchar(50);
set @tblName = 'GivenTable';
SELECT o.name as TableName, i.name AS IndexName
FROM sysobjects o, sysindexes i
WHERE (o.id = i.id and o.name = @tblName) AND (i.status = 18450 OR i.status = 2097152)
i.status = 18450 indicates a clustered index (or, primary key index) in the given table. i.status = 2097152 indicates a non-clustered index in the given table.

Note: @tblName is input parameter to the query. This query is applicable for MS SQL Server 2000.

Jaya Nehru Kumar
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
Please rate this item (5=best)
 1  2  3  4  5
advertisement
advertisement