Solved

delete rows when matching data

Posted on 2011-02-28
2
312 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
2 Comments
 
LVL 40

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Connection String 16 43
Visual Studio TFS - how do I check in my code? 2 29
Code works but it's slow 24 42
Sql Query 4 16
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now