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 |
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-12-05 : 07:53:01
|
| I have a SQL Server 2005 tablePayment_ScoresReference DebtorNo Percent Score--------- -------- ------- -----1234567 2 89 5which I need to loop through and then populate the fields 'Percent' and 'Score' in a tableDebtorDebtID DebtorNo Percent Score------ -------- ------- -----10134 2 (null) (null)by matching the 'DebtID' and 'DebtorNo' after matching the 'Code' field in tableDebtCode DebtID---- ------3234567 445671234567 101348123456 22657so I end up with table Debtor beingDebtID DebtorNo Percent Score------ -------- ------- -----10134 2 89 5How can I acheive this please? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-05 : 07:58:04
|
With ordinary JOINs.UPDATE xSET x.percent = ps.percent, x.score = ps.scoreFROM Payment_Scores AS psINNER JOIN Debt AS d ON d.Code = ps.ReferenceINNER JOIN Debtor AS x ON x.DebtorNo = d.DebtID E 12°55'05.63"N 56°04'39.26" |
 |
|
|
OldMySQLUser
Constraint Violating Yak Guru
301 Posts |
Posted - 2008-12-05 : 08:39:25
|
| Much appreciated. |
 |
|
|
|
|
|