• You have no indexes on DRTemp that support that query.

    Add an index (CUSTNO, DRDATE) INCLUDE (ID)

    This index is likely useless

    CREATE NONCLUSTERED INDEX [IX_DRTemp] ON [dbo].[DRTemp]

    (

    [ID] ASC,

    [DRNo] ASC,

    [CustNo] ASC

    )

    It has the same leading column as the clustered index, with a wider key. Drop it. Any queries that use it can use the clustered index.

    I would also suggest that you drop this:

    CONSTRAINT [IX_DRSummTemp] UNIQUE NONCLUSTERED

    (

    [DRID] ASC,

    [StyleNo] ASC

    )

    and replace it with

    CREATE UNIQUE NONCLUSTERED INDEX IX_DRSummTemp

    ON DRSummTemp

    (

    [DRID] ASC,

    [StyleNo] ASC

    )

    INCLUDE (Quantity, Cost)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass