• ok, maybe i'm wrong here, but I believe there is no need to use sp_msForEachDB:

    that dmv creates ALL the missing indexes in for All databases that meet the missing index criteria.

    for example, even though i ran it in a different database(master), it gave me a suggestion for the database "NewGeo"

    CREATE INDEX

    [missing_index_163_162_CITYDATA]

    ON [NewGeo].[dbo].[CITYDATA] ([STATE])

    INCLUDE ([COUNTYNAME])

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!