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 2012 Forums
 Transact-SQL (2012)
 Delete Rows having same value for one column

Author  Topic 

Sadhu
Starting Member

14 Posts

Posted - 2014-09-11 : 01:12:37
Hi..Please find the sample data below :
WID | ApproverID | HID | ResponsibleID
33507 722 2 990
33507 2696 1 990
33507 990 1 990
33508 2784 2 1252
33508 1252 1 1252
33508 2652 1 1252

Now, for each WID, I want to delete the rows having same value for HID and having ResponsibleID = HID

For example, from the above data, the rows highlighted in RED should be deleted.

Thanks in Advance!


gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-11 : 09:29:13
delete from mytable
where ResponsibleID = HID
Go to Top of Page
   

- Advertisement -