Solved

Checking 2 columns in 2 tables row by row using ssis

Posted on 2008-06-11
1
219 Views
Last Modified: 2011-10-19
hi,
i have 2 tables   A and B. i attached a file below.
i have a task to check each value of column A with each value of column B.
iF if value 30 exist in A and Not present in B.
we should get  a result set "30 deleted from A". and if New values found in B it should be entered into other resultset.
I am trying to work it out through SQL server 2005 or SSIS
i am not able to find a way.
please help
New-Text-Document.txt
0
Comment
Question by:kgadde
1 Comment
 
LVL 2

Accepted Solution

by:
howyue earned 250 total points
ID: 21766033
ur question sounds to me like a synchronization between 2 tables. there are many ways of doing this, based on ur situation, for example using TableDiff provided by sql 2005, using 3rd party program, using storedprocedure or query. i did once before using storedprocedure synchronizing 2 database in different region using linked server, which suited my circumstance.

to give u a rough idea how to do it in query, check out my sample code.
/* Get whatever value exist in table A but not table B */
INSERT INTO B
SELECT A.Value 
FROM A
LEFT JOIN B 
	ON A.Value = B.Value /* u need to specify all the columns to compare here */
WHERE B.Value IS NULL
/* Get whatever value exist in table B but not table A */
INSERT INTO A
SELECT B.Value 
FROM B
LEFT JOIN A
	ON A.Value = B.Value /* u need to specify all the columns to compare here */
WHERE A.Value IS NULL

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Email Notifications for SQL 2005 9 35
Query group by data in SQL Server - cursor? 3 47
Connection to multiple databases 13 25
Merge two rows in SQL 4 25
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Copy Database Wizard 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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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