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
 General SQL Server Forums
 New to SQL Server Programming
 Deleting matched records with a twist

Author  Topic 

emurphy4
Starting Member

17 Posts

Posted - 2009-11-18 : 15:30:59
I need to delete records that match on several fields, but one field(trans_type_cd) shouldn't match. In the example below, I would want to delete the first 8 rows, but the last 2 should remain since they contain 'B1' and don't have a matching 'B2' record. Please let me know if I should provide more detail. Thanks in advance. This is sql server 2008.

tran_type_cd service_dt script_id days_supply_nbr
B1 8/9/2008 0 7
B2 8/9/2008 0 7
B2 6/9/2009 1796 30
B1 6/9/2009 1796 30
B1 6/10/2009 1812 30
B2 6/10/2009 1812 30
B1 7/2/2009 2428 30
B2 7/2/2009 2428 30
B1 7/2/2009 2428 30
B1 7/22/2009 3155 30

emurphy4
Starting Member

17 Posts

Posted - 2009-11-19 : 09:33:59
Is there more information that I could provide that would help?

Thanks.
Go to Top of Page
   

- Advertisement -