Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Find list of existing indices

Author  Topic 

kumarich1
Yak Posting Veteran

99 Posts

Posted - 2007-11-27 : 14:42:34
I am looking for a script to find list of indexes on a table.

Thanks

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2007-11-27 : 14:52:07

select o.name as 'Table', i.name as 'Index',
case indid
when 0 then 'Primary Key'
when 1 then 'Clustered'
else 'Non-clustered'
end as 'IndexType'
from sysindexes i
join sysobjects o on o.id = i.id
where o.xtype = 'U' --User Tables 'V' is Views 'S' is System Tables
order by 1,indid,2


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-11-28 : 02:46:23
Or sp_indexes.
Go to Top of Page
   

- Advertisement -