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 |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2009-12-16 : 06:44:00
|
| Hi,I've got these two tables (simple example)Table1Name NumberNULL 1NULL 2NULL 3Table2Name NumberAlpha 1Beta 2Gamma 3I want to update the name in table1 with the name from table2 where the numbers matchHow can I do that?Thanks |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-16 : 06:48:32
|
| update t1 set t1.name=t2.name from Table1 t1 inner join Table2 t2 on t1.number=t2.numberSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2009-12-16 : 06:56:01
|
| Thanks!This is the actual SQLUPDATE dbPubMatrix..tblLoRenewals SET dbPubMatrix..tblLoRenewals.salesperson = EMATRIXBCK..tblLoRenewals.salespersonFROM dbPubMatrix..tblLoRenewals INNER JOIN EMATRIXBCK..tblLoRenewals ONdbPubMatrix..tblLoRenewals.id = EMATRIXBCK..tblLoRenewals.idI get this errorThe objects "EMATRIXBCK..tblLoRenewals" and "dbPubMatrix..tblLoRenewals" in the FROM clause have the same exposed names. Use correlation names to distinguish them.Can you help?Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-16 : 07:07:38
|
| UPDATE t1SET t1.salesperson = t2.salespersonFROM dbPubMatrix..tblLoRenewals as t1 INNER JOIN EMATRIXBCK..tblLoRenewals as t2 ONt1.id = t2.idMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|