Tuesday, October 26, 2010

Find Index’s Table Name


At times i came across situations when i need to search for particular index name and on which table it is and for which database. To help me out i came across with this small piece of code yet very useful. So posting it out thought might help out.


EXEC sp_MSforeachdb 'USE ?
select ''?'' as DatabaseName, as TableName, as IndexName from sys.indexes si
inner join sys.tables st
si.object_id = st.object_id
where like ''%INDEXNAME%'''

No comments:

Post a Comment