Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How can I make this deletion

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2009-04-03 : 04:07:44
Hai
I have two tables CUSTOMERTB and QUOTATIONTB. How can I make a condition such that I can delete a customer from CUSTOMERTB if he has no quotations in QUOTATIONTB
custId (primary key) in CUSTOMERTB is foreign key in QUOTATIONTB

Thanks and Regards
Anu Palavila

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-03 : 04:55:12
try this one
delete from CUSTOMERTB where custId in (select t.empid from CUSTOMERTB t left join QUOTATIONTB e on e.custId = t.custId
where e.custId is null)
Go to Top of Page

Naigewron
Starting Member

6 Posts

Posted - 2009-04-03 : 06:05:29
Would this work, or am I missing a piece of info here?

DELETE FROM CUSTOMERTB WHERE custId NOT IN (SELECT custId FROM QUOTATIONTB)
Go to Top of Page
   

- Advertisement -