sybase get the global index

saibsk
saibsk used Ask the Experts™
on
I need to find all the global indexes on a particular table. I know ic an use sp_helpindex. But i needs just the index names,
columns that form the index and the only the global indices in sybase ase server.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
This gives name of global indexes:

select name
from sysindexes
where id = object_id('Mytable')
and (status3 & 8 != 8)

But finding out key columns is tricky, you need to use index_col function for each column:

select name "Index", index_col('Mytable', indid, 1), index_col('Mytable', indid, 2), index_col('Mytable', indid, 3), .... -- as many as you like to see
from sysindexes
where id = object_id('Mytable')
and (status3 & 8 != 8)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial