October 29, 2015 at 4:25 pm
I have an entry in the system.indexes table for an index that no longer exists on the table. How can I remove this?
October 29, 2015 at 11:51 pm
Steve Hurst (10/29/2015)
I have an entry in the system.indexes table for an index that no longer exists on the table. How can I remove this?
How have you determined that the index no longer exists?
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2015 at 3:03 am
Two things, first the index does not show against the table in SSMS under the Tables (table_name) Indexes. Second, it came to light when running a script to rebuild the index:
IF EXISTS (SELECT name FROM sys.indexes WHERE name = 'part_needi17')
DROP INDEX part_needi17 ON part_need
This fails because the If EXISTS returns True and then the DROP fails.
October 30, 2015 at 3:10 am
Index names aren't unique across the database. You must have an index called part_needi17 on a different table.
John
October 30, 2015 at 3:55 am
Steve Hurst (10/30/2015)
Two things, first the index does not show against the table in SSMS under the Tables (table_name) Indexes. Second, it came to light when running a script to rebuild the index:IF EXISTS (SELECT name FROM sys.indexes WHERE name = 'part_needi17')
DROP INDEX part_needi17 ON part_need
This fails because the If EXISTS returns True and then the DROP fails.
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'part_needi17'
AND object_id = OBJECT_ID('part_need')
DROP INDEX part_needi17 ON part_need
To find out what table the index is associated with:
SELECT TableName = object_name(object_id), *
FROM sys.indexes
WHERE name = 'part_needi17'
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply