Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Compare two tables in ssis

Author  Topic 

aswindba1
Yak Posting Veteran

62 Posts

Posted - 2012-12-05 : 13:25:13
I want to insert values in to “Table B” from “Table A”. Both the tables has only two columns and same.

Table B is destination table and it's constant. Table A is getting Updated every week.
So I have to extraxt the data from table A and compare with table B and updated.



If the data is not exists in “Table B” I want to insert values from “Table A”
If the data is exists in both tables do not do anything. (Like eliminating the duplicates).
Insert only updated data from Table A in to table B


I want to implement this by SSIS. Which component can i use in SSIS , and how ?

Tell me in step by step, I am very new in SSIS

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-12-05 : 15:18:14
Create a stored procedure to do the merging. The stored procedure would contain code like this:
INSERT INTO TableB
(col1, col2)
SELECT
col1,col2
FROM
TableA a
WHERE NOT EXISTS
(
SELECT * FROM TableB b
WHERE b.col1 = a.col1 AND b.col2 = a.col2
);


Then, create an Execute SQL Task in SSIS and have it call that stored procedure.
Go to Top of Page

aswindba1
Yak Posting Veteran

62 Posts

Posted - 2012-12-05 : 16:03:38
Awesome..its working fyn
Thank you very much..I appreciate your help
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2012-12-05 : 17:39:50
If your requirement is complex .check this out
http://www.sqlis.com/post/Get-all-from-Table-A-that-isnt-in-Table-B.aspx

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-06 : 01:59:30
there are lots of methods

1. T-sql using LEFT JOIN,NOT EXISTS,NOT IN
2. t-sql MERGE statement
3. SSIS using Lookup
4. SSIS using Merge Join etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -