Pages

Tuesday, October 26, 2010

Find Index’s Table Name

Hello!!..

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.

Query:

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

No comments:

Post a Comment