[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

delete rows when matching data

Hi Experts

I populate a sql server 2008 DB table from SAP using a web service in C#.net 2010 and when that tables gets populated i want to be able to see if another table has a certain field(PART NUMBER) that matches the populated table from SAP and if matches then remove row from populated SAP table?

Thanks
0
razza_b
Asked:
razza_b
1 Solution
 
SharathData EngineerCommented:
try any of these. Make sure that you have the backup of this table before running the DELETE command in case if you want to retain the data.
DELETE FROM AnotherTable 
      WHERE Part_Number IN (SELECT Part_Number 
                              FROM SAP_Table);

Open in new window

DELETE FROM AnotherTable 
      WHERE EXISTS (SELECT 1 
                      FROM SAP_Table 
                     WHERE AnotherTable.Part_Number = SAP_Table.Part_Number);

Open in new window

0
 
razza_bAuthor Commented:
Thanks, will try this once i get a chance will let you know.

cheers!!
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now