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 |
|
Elvira
Starting Member
4 Posts |
Posted - 2010-04-30 : 02:56:18
|
| Hello,If some one can suggest me something good about:How to update records in table by using other table only if the data values in the tables are different (where table1.id=table2.id)? |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2010-04-30 : 03:10:49
|
| [code]UPDATE TSET data = t1.dataFROM Table_1 TJOIN Table_2 T1ON t.id = t1.idAND t.data <> t1.data[/code] |
 |
|
|
Elvira
Starting Member
4 Posts |
Posted - 2010-04-30 : 03:30:29
|
| What if i have 3d table (t3.importID=t2.importID). I need to update t3 also if data in t1 and t3 are different. Tables connected by: t1.id=t2.id, t3.importid=t2.importID (t1-source table and it has some column from t2 and some from t3). |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-04-30 : 03:30:46
|
| Might need to also test if either T.data or T1.data, but not both!, are NULL |
 |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2010-04-30 : 10:26:49
|
| where (t.data is null and t1.data is not null) or (t1.data is null and t.data is not null)Terry-- The problem with socialism is that you eventually run out of other people’s money. -- Margaret Thatcher |
 |
|
|
|
|
|