• I did not post the query as I can't post it as is and what I can post might not be useful at all. Find below a query with renamed tables/columns. I only posted this in case someone else comes across this problem as I've already found a workaround.

    SELECT

    A.a_id,

    C.c_id,

    B.b_id,

    D.d_id,

    E.e_id,

    F.g_id

    FROM table_G G

    INNER JOIN

    table_A A

    ON A.a_id = G.a_id

    INNER JOIN

    table_C C

    ON C.c_id = G.c_id

    LEFT JOIN

    table_B B

    ON B.a_id = A.a_id

    LEFT JOIN

    table_D D

    ON D.b_id = B.b_id AND D.c_id = G.c_id

    LEFT JOIN

    table_E E

    ON E.e_id = COALESCE(D.e_id, C.e_id)

    LEFT JOIN

    table_F F

    ON F.g_id = G.g_id

    WHERE

    F.g_id IS NULL

    AND A.created < DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)

    The problem line I spoke of was "AND A.created ..." - table Table_A contains around a million records. Simply removing that line worked and putting the "DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)" into variable and using variable instead also worked.