I have two tables A and B each with common field "Policy No". I want to delete from B all records which are not in A, based on the policy number. Can someone show me how to do this? Thanks
Something like this ?
DELETE FROM B
WHERE [Policy No] Not In (SELECT [Policy No] FROM A);
Or this ?
DELETE B.* FROM B LEFT JOIN A ON B.[Policy No] = A.[Policy No]
WHERE A.[Policy No] Is Null;
Or this ?
DELETE FROM B
WHERE Not EXISTS (SELECT * FROM A WHERE A.[Policy No]=B.[Policy No]);
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.