• you are joining to sys.indexes which will cause the results to only be returned for the current execution database.

    You will need to run the same thing against each database. It doesn't really matter where you place the proc.

    Yes, msforeachdb can miss databases. You can create a cursor to loop through each database and execute a dynamic sql string.

    I am curious to know why you are ignoring heaps.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events