Solved

Checking 2 columns in 2 tables row by row using ssis

Posted on 2008-06-11
1
216 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
Comment Utility
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.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle Pivot 2 32
phpMyAdmin simple sql statement 3 39
union query and alias columns  - SQL Server 2 36
Select2 jquery help 9 41
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

12 Experts available now in Live!

Get 1:1 Help Now