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 |
|
samrat
Yak Posting Veteran
94 Posts |
Posted - 2002-10-24 : 01:55:50
|
| Greetings,I m looking for a solution on a update query. Following is a prototype table structure and sample dataTable 1 Field1 Field2 A 1 B 2 C 3 D 4 Table2 Field1 Field2A NULLD 4B NULLA 1C 3D NULLB NULLI wanna write a update statement, to update the NULL values in Field2(Table2) as per the corresponding values in Table1.Regards,SamratEdited by - samrat on 10/24/2002 02:10:03 |
|
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2002-10-24 : 05:14:17
|
| I think this whould work.update table2 set field2 =(select field2 from table1 where table1.field2=table1.field1) and table2.field2 is nullHarsh. |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-10-24 : 06:49:19
|
I think this whould work better.update table2set field2 =(select field2 from table1 where table1.field2field1=table1.field1)andwhere table2.field2 is null ...or I like...update table2set field2 = b.field2from table2 a inner join table1 b on a.field1 = b.field1where a.field2 is null Jay White{0} |
 |
|
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2002-10-24 : 07:11:05
|
ok ya that was my error |
 |
|
|
samrat
Yak Posting Veteran
94 Posts |
Posted - 2002-10-24 : 21:47:36
|
| Thanx guyz.. It works well...RegardsSamrat |
 |
|
|
|
|
|