• The code is part of a stored procedure which bulk inserts data from a csv file, using a Staging table.

    Thanks for the hint. Job for later.

    Cheers,

    Julian

    gbritton1 (5/6/2014)


    Some other things to consider:

    1. Do you have indices on the join columns? (MWID, [Org Eenheid Code], BEGINDATUM)

    2. If you have an index on BEGINDATUM, the expression

    DATEPART(ISO_WEEK,A.BEGINDATUM)= DATEPART(ISO_WEEK,B.BEGINDATUM)

    will stop SQL server from using that index (Since it's a function call it's not a SARG). To get around that, try to reformulate it as

    BEGINDATUM > <beginning of the week> AND BEGINDATUM < <beginning of following week>