Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verification on script to retrieve the indexes on a table
Message
From
13/03/2008 17:28:15
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Scripting
Title:
Verification on script to retrieve the indexes on a table
Miscellaneous
Thread ID:
01301985
Message ID:
01301985
Views:
60
I need to verify that script which is used to select the indexes from a table. I thought I had it running ok but it is not the case. This script doesn't find any of my indexes on a table. I do have some so I guess something need to be adjusted.
DECLARE tableIndexes CURSOR LOCAL FOR
SELECT name FROM sysindexes
WHERE id = OBJECT_ID(N'ArchiveRetrieval') AND
 indid > 0 AND indid < 255 AND
 INDEXPROPERTY(id, name, 'IsStatistics') = 0 AND
 name <> (SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
 WHERE CONSTRAINT_TYPE = 'PRIMARY KEY' AND TABLE_NAME = '[ArchiveRetrieval]')
ORDER BY indid DESC
If I remove the second part, all the indexes are found. But, I need it as I do not want to select an index which is used as a primary key.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform