Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list your database table indexs.

Status
Not open for further replies.

mickyang

Programmer
Jan 15, 2002
6
TW
select so.name as TableName, sind.name as PKName,
case
when (sind.status & 0x800) = 0x800 then 'PK'
else 'IX'
end as IndexType,
sik.keyno, col.name as ColName ,
case
when sind.indid = 1 then 'Yes'
else ''
end as 'Clustered Indexes'
from sysobjects so
inner join sysindexes sind on so.id=sind.id
inner join sysindexkeys sik on sind.id=sik.id and sind.indid=sik.indid
inner join syscolumns col on col.id=sik.id and col.colid=sik.colid
where so.xtype = 'U'
and sind.root <> 0x0 -- this should eliminate stats
order by so.name, sik.keyno

PS:MUST HAVE DATA IN YOUR DATABASE TABLES.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top