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 |
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-03-26 : 02:38:27
|
| i have 2 tabletable :id,col1,col2,col3,col4...,col10and table2 which was imported from a fileid,col1,col2and i wantto update all matching rows in table1 from table 2wheretable1.id=table2.idtable1.col3=table2.col1table1.col7=table2.col2how can i do this?thnaksi n advancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-26 : 03:04:24
|
[code]update t1set t1.col1 = t2.col1, t1.col2 = t2.col2from table1 t1 inner join table2 t2 on t1.id = t2.idwhere t1.col1 <> t2.col1or t1.col2 <> t2.col2[/code] KHChoice is an illusion, created between those with power, and those without.Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant |
 |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-03-26 : 03:45:19
|
| thnaks aloti dont need this partwhere t1.col1 <> t2.col1or t1.col2 <> t2.col2beacuse i want to update as is whithiguht checkign the dtatIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-26 : 04:52:41
|
Is this update going to be a one off things or you plan to run this regularly ? If you plan to run this regularly, it will be updating all records regardless of weather there are any changes or not. KHChoice is an illusion, created between those with power, and those without.Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant |
 |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-03-26 : 05:35:54
|
| why do u say that?Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
|
|
|
|
|