Bonjour,
Je suis à la recherche d un script me listant l ensemble des index pour chaque table .
Pouvez vous m indiquer les tables que je dois utiliser tant en 2000 que 2005.
merci d avance
Cldt
L
Version imprimable
Bonjour,
Je suis à la recherche d un script me listant l ensemble des index pour chaque table .
Pouvez vous m indiquer les tables que je dois utiliser tant en 2000 que 2005.
merci d avance
Cldt
L
Bonjour,
Pour SQL Server 2005 et 2008, vous pouvez utiliser la requête que j'ai publié ici.
Pour SQL Server 2000, je n'ai pas de requête ni d'instance SQL Server 2000 sous la main, mais vous devrez utiliser les tables sysindexes et sysindexkeys.
Si, comme dans la requête que j'ai publié pour SQL Server 2005 et 2008, vous pouvez joindre la table syscolumns.
@++ ;)
Comme les tables système de SQL Server 2000 sont encore compatibles sous SQL Server 2008, voici la requête pour les index sous SQL Server 2000 :
Et avec les colonnes :Code:
1
2
3
4
5
6
7
8
9
10
11
12 SELECT T.name AS table_name , I.name AS index_name , CASE I.indid WHEN 1 THEN 'CLUSTER' ELSE 'NON-CLUSTER' END AS index_type FROM sysindexes AS I INNER JOIN sysobjects AS T ON I.id = T.id WHERE T.type = 'U' AND I.name NOT LIKE '%_!WA!_Sys!_%' ESCAPE '!' AND I.indid > 0 ORDER BY T.name, I.name
@++ ;)Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 SELECT T.name AS table_name , I.name AS index_name , CASE I.indid WHEN 1 THEN 'CLUSTER' ELSE 'NON-CLUSTER' END AS index_type , C.name AS column_name , IK.keyno AS index_key_col_pos FROM sysindexes AS I INNER JOIN sysobjects AS T ON I.id = T.id INNER JOIN sysindexkeys AS IK ON I.id = IK.id AND I.indid = IK.indid INNER JOIN syscolumns AS C ON IK.id = C.id AND IK.colid = C.colid WHERE T.type = 'U' AND I.name NOT LIKE '%_!WA!_Sys!_%' ESCAPE '!' AND I.indid > 0 ORDER BY T.name, I.name
Oui... merci.... je voulais écrire le script moi-même.... ré inventer le fil à couper le beurre en fin de compte.
en tout cas, c est sympa!
Cldt
L