Solved

Checking 2 columns in 2 tables row by row using ssis

Posted on 2008-06-11
1
218 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Pivot Rows To Columns 10 53
What query can i write to find where a function is 4 34
Add different cell to otherwise similiar row 4 39
SQL Error - Query 6 25
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

772 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