• blindly adding an index on all the columns that foreign keys are involved with might not help much;

    it's the selectivity of the data that is what the SQL engine uses to determine whether to use an index or not.

    so for example, if you have a column in a table that is foreign keyed to toa STATUS table that has three values(ie, open, closed,cancelled) , the index is not very selective; your data would probably have 90% of the data in two of the values.

    indexes on other items might actually help.

    The second post I ever did on SSC asked that exact question:

    http://www.sqlservercentral.com/Forums/Topic11946-8-1.aspx, and there's a bit of discussion on it.

    if you really insist you need a script that blindly builds the indexes on foreign keys if they do not exist yet, I'll post it as a follow up.

    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!