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)
 How to compare data in two tables using SSIS

Author  Topic 

sqlsundar
Starting Member

2 Posts

Posted - 2007-10-21 : 20:13:43
Hi there-

Here is my situation.

I have got Table A in database DB1 and Table B in database DB2 with same table structure. I need to compare the data in table A and Table B and add the missed records in Table B.

Can anyone help me on how to do this in a SSIS Package?

Thanks,
Sundar.

nr
SQLTeam MVY

12543 Posts

Posted - 2007-10-21 : 20:21:34
Well a sql statement would do it if they are on the same server.
You could also use a merge join after sorting the two inputs and insert the unmatched rows.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sqlsundar
Starting Member

2 Posts

Posted - 2007-10-21 : 20:43:19
Hi-

Thanks for the reply. Okay, I will write a sql query to compare this.
I am new to SSIS. Please let me know which control in Data flow should I use for that? If possible let me also know, what are all the controls I may need to use to accomplish the entire task I have mentioned?

Thanks in Advance.

Regards,
Sundar.
Go to Top of Page

amarnathms
Starting Member

1 Post

Posted - 2007-11-05 : 08:48:01
Hello Sundar,

Did you find the solution for your problem. I do have a same situation to compare two tables on two database and insert only the missed records.

Thanks
Amarnath
Go to Top of Page

chosen320
Starting Member

2 Posts

Posted - 2009-02-02 : 04:41:19
Hi. Just wondering if any of you came up with a solution to this? I currently need to do the same thing.

Thanks in advance
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-02 : 08:52:13
two approaches. see below

http://www.sqlis.com/post/Get-all-from-Table-A-that-isnt-in-Table-B.aspx
Go to Top of Page

chosen320
Starting Member

2 Posts

Posted - 2009-02-02 : 09:14:33
Thanks for the response.

Getting missing data was the simpler of my 2 targets. I also need to compare the actual content of existing data to see whether it has changed. This is for a data warehouse.

The most resource efficient method I've found so far is by comparing checksums of each row. If the checksums are different then obviously my data-warehouse needs an updated copy of the information from the source server.

I found this useful... http://www.dbforums.com/microsoft-sql-server/1215456-best-way-compare-two-entire-rows-seperate-tables.html

I will need to work on a variation of that resource though, because my datawarehouse tables have extra columns that the source databases don't have.

But I should be able to work around that by dynamically working out which columns to calculate the check sums on using the information_schema views provided by SQL server.

Go to Top of Page
   

- Advertisement -