Hi roryp 96873
I had to modify the code as it does not like '-' in the database name so i bracketed them. I also concatenated the database name to the index so you know where the index resides as it is in more than one database in my case.
Jim
code generates sql to find an index in every database
select
'select ' + '''[' + name + '].''' + '+ name from [' + name + '].sys.indexes i where i.name = ''AllDocs_PK'''
from
master.sys.databases
where
name not in
(
'master',
'tempdb',
'model',
'msdb'
);
go