Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Verification on script to retrieve the indexes on a table
Message
De
13/03/2008 17:28:15
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Titre:
Verification on script to retrieve the indexes on a table
Divers
Thread ID:
01301985
Message ID:
01301985
Vues:
61
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform