I will try to make this as clear as possible. My main objective is to "Identify" and then "Delete" records found between two tables. I've solved the first part of "Identifying" the records that needs to be deleted, however, I'm a little stuck on how to delete the 370K records found. The below query is what I use to locate the records: It works fine.
SELECT TABLE1.COLUMN1 AS ACCOUNTS, TABLE2.COLUMN1 AS COMPANY_HQ
FROM TABLE1, TABLE2
WHERE TABLE1.ACCOUNT + '%%%%%%' LIKE '%%%%%%' + TABLE2.COMPANY_HQ + '%%%%%%'
ORDER BY TABLE2.COMPANY_HQ ASC;
(see attached file for results)
Now...I'm using the below query to delete the records found in Table2:
DELETE FROM TABLE2
WHERE TABLE2.ACCOUNT + '%%%%%%' LIKE '%%%%%%' + TABLE1.COMPANY_HQ + '%%%%%%'
BUT...I get the below error message:
Msg 4104, Level 16, State1, Line 2
The multi-part identifier "TABLE2.COMPANY_HQ" could not be bound.
I apologize for any confusion. Any assistance in this matter would be greatly appreciated.