• Antares686 - Tuesday, July 25, 2017 9:36 AM

    Phil Parkin - Tuesday, July 25, 2017 8:49 AM

    Another thing you could try, if you are unable to post the detailed information being requested, is breaking down the queries into multiple steps and using well designed temp tables to store intermediate results.
    Eg, create an indexed temp table containing the results of running
       SELECT ACCT
        FROM dbo.TABLEB
        WHERE
           FSCD IN ('BIQ', 'BCU')

    and then you can modify your subsequent query to use the temp table.

    That's what we ended up doing to resolve it. Using a Table Variable in place of the query and it is more than happy with that. But this behavior difference is a mystery.

    I suggest that you try using temp tables rather than table variables. They often perform better and rarely perform worse.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.