Hi Neal
I think there's some confusion here because of this...
delete ALL records from 'Column 0'
and this
delete ALL other [Column 0] records
I reckon what you mean to say is this: if a matching row is found in dbo.ABN_File_Header, then delete all rows in dbo.abn_extract, otherwise don't delete any.
The all-or-nothing nature of this requirement suggests the use of IF:
IF (SELECT COUNT(*)
FROM dbo.abn_extract E
JOIN dbo.ABN_File_Header H
ON SUBSTRING(E.[Column 0], 1, 13) = H.Header_Id) > 0
BEGIN
DELETE FROM dbo.abn_extract
END
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden