table names for indexes

  • I'm trying to automate drop indexes but cannot find the relationship between sysindexes I and sysobjects O. O.id does not seem to correlate with I.id. Per a system catalog I have this sould work. What am I missing??

    Terry


    Terry

  • Yes, they join on ID. What is the exact query you have created?

  • select o.name, i.name from sysindexes i, sysobjects o where i.name

    like '_WA_Sys%' and o.id = i.id

    I didn't think it's that complex. However, it doesn't seem to work based on my application.

    Terry


    Terry

  • A better SQL syntax for your query shoyuld be as here:

    select o.name, i.name

    from sysindexes i

    join sysobjects o

    on i.name like '_WA_Sys%'

    and o.id = i.id

    However, why are you checking for '_WA_Sys%'? Is it to limit your query to the user-defined objects? In that case use the following:

    select o.name, i.name

    from sysindexes i

    join sysobjects o

    on o.type = 'u'

    and o.id = i.id

    Your approach is not safe. For example, it won't work if an index name was specified explicitly.

    Edited by - mromm on 07/30/2003 1:21:59 PM

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply