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.
| Author |
Topic |
|
evanburen
Posting Yak Master
167 Posts |
Posted - 2007-03-01 : 10:54:17
|
| I have a set of data in Table1 and I bring all new data into it weekly (all records) from another party. My challenge is that I need to find out which records have changed from week to week. I was thinking of just importing the new weekly data into a separate table (Table2) and compare the values. Could anyone point me in the right direction? ThanksTable1IDRatingARatingBRatingCTable2IDRatingARatingBRatingC |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-01 : 10:57:03
|
[code]select *from Table1 t1 inner join Table2 t2on t1.ID = t2.IDwhere t1.RatingA <> t2.RatingAor t1.RatingB <> t2.RatingBor t1.RatingC <> t2.RatingC[/code] KH |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-03-01 : 10:57:15
|
| select *from Table1 t1join Table2 t2on t1.ID = t2.IDwhere t1.RatingA <> t2.RatingAor t1.RatingB <> t2.RatingBor t1.RatingC <> t2.RatingCdo you want records that are new or deleted? Do you have nulls?==========================================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. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-01 : 11:01:48
|
use FULL OUTER JOIN instead of INNER JOIN if you have new records and would like to identify which records is missing from which table. KH |
 |
|
|
|
|
|