Re: DELETE ... NOT query does not delete all that I expected
- From: "Plamen Ratchev" <Plamen@xxxxxxxxxxxxx>
- Date: Wed, 23 Jan 2008 15:35:54 -0500
You are experiencing this because one or both columns 'originator' and 'beneficiary' have NULL values. Boolean logic with NULLs goes like this:
NOT TRUE -> FALSE
NOT FALSE -> TRUE
NOT UNKNOWN -> UNKNOWN
Since your WHERE filter evaluates to UNKNOWN when 'originator' and 'beneficiary' has NULL value, the DELETE skips those rows.
To delete the correct rows you can write the query like below:
DELETE FROM #details
WHERE NOT ((originator = 'J' AND originator IS NOT NULL)
AND (beneficiary = 'V' AND beneficiary IS NOT NULL))
HTH,
Plamen Ratchev
http://www.SQLStudio.com
.
- References:
- DELETE ... NOT query does not delete all that I expected
- From: metaperl
- DELETE ... NOT query does not delete all that I expected
- Prev by Date: Re: Months Between
- Next by Date: Re: How top actually works
- Previous by thread: DELETE ... NOT query does not delete all that I expected
- Next by thread: Re: DELETE ... NOT query does not delete all that I expected
- Index(es):