Solved

delete rows when matching data

Posted on 2011-02-28
2
316 Views
Last Modified: 2012-05-11
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
Comment
Question by:razza_b
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
Sharath earned 500 total points
ID: 35004282
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
 
LVL 1

Author Comment

by:razza_b
ID: 35004407
Thanks, will try this once i get a chance will let you know.

cheers!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question