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 2005 Forums
 Transact-SQL (2005)
 compare two table and delete duplicate records

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-03-09 : 08:33:55
HEMANT writes "Hi;
I am geting problem i have two tables naming old_companies and suspended_companies i want to delete the company name from old_companies that are in table suspended_companies please send me the query that will help me out.

thanking you
Hemant"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-09 : 08:37:11
[code]
delete o
from old_companies o inner join suspended_companies s
on o.company_id = s.company_id
[/code]


KH

Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2007-03-12 : 04:36:55
quote:
Originally posted by AskSQLTeam

HEMANT writes "Hi;
I am geting problem i have two tables naming old_companies and suspended_companies i want to delete the company name from old_companies that are in table suspended_companies please send me the query that will help me out.

thanking you
Hemant"



Delete From Old_Companies Where Old_Company_ID IN (Select Suspended_Company_Id From Suspended_Company)

KHTAN: Which query will be faster?

Mahesh
Go to Top of Page
   

- Advertisement -