• You can use the un-documented SP "sp_MSforeachdb" for this

    IF OBJECT_ID('tempdb..#tmp_Indexes') IS NOT NULL

    DROP TABLE #tmp_Indexes

    DECLARE@strSQLVARCHAR(2000)

    DECLARE@IndexName VARCHAR(1000)

    CREATE TABLE #tmp_Indexes

    (

    DatabaseNameVARCHAR(100),

    IndexNameVARCHAR(1000)

    )

    SET@IndexName = 'mst_Employees_IX01' -- You can enter the name of the index here

    SET@strSQL = ' SELECT ''?'', name FROM ?..sysindexes WHERE name LIKE ''%' + @IndexName + '%'' '

    INSERT#tmp_Indexes( DatabaseName, IndexName )

    EXECUTE sp_MSforeachdb @strSQL

    SELECT * FROM #tmp_Indexes

    IF OBJECT_ID('tempdb..#tmp_Indexes') IS NOT NULL

    DROP TABLE #tmp_Indexes

    Edit: Added a comment in the code


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/