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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2009-10-12 : 07:56:12
|
| i have 2 tables t1 and t2 now I want to update t1 with all fields from t2 that are not null. If it is null I want to keep the old data.How would I do this? |
|
|
sanoj_av
Posting Yak Master
118 Posts |
Posted - 2009-10-12 : 08:04:36
|
| UPDATE T1 SET T1.COLUMN1=ISNULL(T2.COLUMN1,T1.COLUMN1), T1.COLUMN2=ISNULL(T2.COLUMN2,T1.COLUMN2), T1.COLUMN3=ISNULL(T2.COLUMN3,T1.COLUMN3)FROM T2 WHERE T1.PRIMARY_KEY=T2.PRMARY_KEY |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-12 : 08:05:12
|
| What is the relation between the two tables?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|