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 |
|
squab
Starting Member
15 Posts |
Posted - 2004-05-22 : 12:42:55
|
Hello,Anybody could help me please. I have 2 tables : A and B (see screenshot below)How I can update column DeviceId from table A with data from table B (A.netAdressId = B.netAdressId) ? Thanks in advance for your help.Regards,SqUaB |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-05-22 : 13:03:56
|
| UPDATE taSET ta.deviceId = tb.deviceIdFROM TableA ta INNER JOIN TableB tb ON ta.netAddressId = tb.netAddressIdMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
squab
Starting Member
15 Posts |
Posted - 2004-05-22 : 17:24:32
|
| Thanks Derrick, but it doesn't work :-(ta = BDDSPSRVNATNV..NetAddresses_Copytb = BDDCTSRVNATNV91..deviceNetAddrRelsUPDATE NetAddresses_CopySET N.deviceId = D.deviceIdFROM BDDSPSRVNATNV..NetAddresses_Copy NINNER JOIN BDDCTSRVNATNV91..deviceNetAddrRels D ON N.netAddressId = D.netAddressIdServer: Msg 1032, Level 15, State 1, Procedure CreateTableNetAddresses_Copy, Line 51Cannot use the column prefix 'N'. This must match the object in the UPDATE clause 'NetAddresses_Copy'.Do you understand why ? |
 |
|
|
DustinMichaels
Constraint Violating Yak Guru
464 Posts |
Posted - 2004-05-22 : 17:57:07
|
| Try chaning it fromUPDATE NetAddresses_CopySET N.deviceId = D.deviceIdFROM BDDSPSRVNATNV..NetAddresses_Copy NINNER JOIN BDDCTSRVNATNV91..deviceNetAddrRels D ON N.netAddressId = D.netAddressIdToUPDATE NSET N.deviceId = D.deviceIdFROM BDDSPSRVNATNV..NetAddresses_Copy NINNER JOIN BDDCTSRVNATNV91..deviceNetAddrRels D ON N.netAddressId = D.netAddressIdThe reason being that your including a from in your UPDATE statement so you need to update with your table alias.Dustin Michaels |
 |
|
|
squab
Starting Member
15 Posts |
Posted - 2004-05-22 : 18:35:03
|
| Many Thanks to all of you ! it's working fine !Best Regards,SqUaB |
 |
|
|
|
|
|