• Well, several issues with this, but the foremost issue is with using

    where ... in (select...)

    Please don't. You already have your IDs in a table and a Primary Key (hopefully clustered) on SalesID in your application table. So just join the tables!

    DELETE

    YourDB.dbo.SalesZIP

    from

    YourDB.dbo.SalesZIP orig

    inner join #InnerTemp dead on orig.SalesID = dead.SalesID