• Have you tried turning the problem around and doing a select of the Dataset & RowNumbers that are missing between the Staging and source tables

    As this should then produce the dataset that you want to delete

    something like this (Needs to be checked that you are getting the rows that are deleted back).

    SELECT [DATASET], [ROWNUMBER]

    INTO #TestTable

    FROM TX_Stage.dbo.XAL_dbo_STOCKTRANS A

    Where NOT EXISTS (Select 1 From [SQLXAL].[XALDRIFT].[dbo].[STOCKTRANS] B

    Where [A].[DATASET]=.[DATASET] AND [A].[ROWNUMBER]=.[ROWNUMBER])

    DELETE B

    FROM TX_Stage.dbo.XAL_dbo_STOCKTRANS_V B

    JOIN #TestTable A on [A].[DATASET]=.[DATASET]

    AND [A].[ROWNUMBER]=.[ROWNUMBER]

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices