• On The server NJACCOUNTING01, look at the indexes on the table marlin_test.dbo.apdoc

    an index like this would greatly help the query, i believe:

    CREATE INDEX IX_apdoc ON dbo.apdoc(Crtd_DateTime,DocType,VendId) INCLUDE (user1,vendid)

    see what indexes are already there, and see if you can replace or modify an existing, or add one like my example above;

    add the index, test your query again, and compare the before and after execution plans to see if ti's worthy of permanent promotion.

    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!