SQL DMO - deleting indexes - cant delete DRI Generated

Hi sql heads - I'm itterating through tables using sqldmo (in vba) and then itterating through indexes on that table and issueing a remove. I have an indexes it refuses to delete, instead giving an error (I didnt write number  down, but can get on request) saying that it can delete a "DRI generated" unique contraint or primary key. An interesting thing to note is that this index is of type 18450, where as most of the other indexes are of a type that can be found on the SQLDMO_INDEX_TYPE index constants page in the books online.

anyhow, is there any way I can delete these with sqldmo?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

These indexes are constraint primary keys. You cannot use same satement which you are using to delete indexes in these case.
if you are using .Indexes property of the object use .keys property.
valhallatechAuthor Commented:
hmm... I thought of that, but the .keys collection was empty, so there was nothing to delete. Though I'll go and look at this again and double check.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

valhallatechAuthor Commented:
hi imran_fast
you're right - at least partly. there is a key - so I used .keys.remove, but this still didnt stop the error (-2147201005) from occuring, and so I still cant delete that index. I also executed a .primarykey.remove, but that still doesnt allow me to delete the index wiht out getting the error:
"[SQL-DMO] This index was generated by a DRI 'PRIMARY KEY' or 'UNIQUE KEY' CONSTRAINT and cannot be modified or droped" when I try the .index(x).remove (having already done .key(x).remove)

where to from here?
Create a Key object.
Set the Type property to SQLDMOKey_Primary.
Add the Key object to the Keys collection of a Table object that exposes the attributes of the SQL Server table.
then use the remove property to delete it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
valhallatechAuthor Commented:
just to confirm - when you say 'then use the remove property to delete it.' - you mean the index, not the new key?
yes to remove  the primary key index
valhallatechAuthor Commented:
bingo - thankyou
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.