Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Verification on script to retrieve the indexes on a tabl
Message
 
 
À
13/03/2008 17:28:15
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Scripting
Divers
Thread ID:
01301985
Message ID:
01302066
Vues:
16
This message has been marked as the solution to the initial question of the thread.
For SQL 2005 and later you can use sys.indexes system view
SELECT name FROM sys.indexes 
	WHERE is_primary_key = 0
		AND OBJECT_name(object_id) = 'ArchiveRetrieval'
>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.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform