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)
 sql

Author  Topic 

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-07-01 : 06:04:20
There are two tables. TableA, TableB
both have one of the fields called FeedID.
The FeedID is a varchar(10)
I would like to delete the FeedID in TableB which are not present in TableA.

In tableB one of the records has FeedID = '20122783'
This FeedID is not present in Table A so I would like to delete this record from TableB

This is the sql that I am using but it does not return this FeedID????

delete from TableB
where FeedID not in (select FeedID from TableA)

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-01 : 06:15:39
Make sure this returns the required Ids

Select FeedId from TableB
where FeedID not in (select FeedID from TableA)



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-07-01 : 06:17:41
i have already tried that, and it does not return anything.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-01 : 06:20:42
Post the table structures with sample data

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2005-07-01 : 06:23:56
How can I compare fiel1, fiel2 in TableA to those in TableB?
Thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-01 : 06:43:03
Use inner Join

Select T1.field1 from tableA t1 inner join tableB t2 on t1.field1=t2.field1
and t1.field2=t2.field2



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -