Solved

delete rows when matching data

Posted on 2011-02-28
2
311 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
Comment Utility
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
Comment Utility
Thanks, will try this once i get a chance will let you know.

cheers!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

771 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

15 Experts available now in Live!

Get 1:1 Help Now