0

I know how to join these two tables (invoices and payables). Payables has a balancedue column and I need to make that the same as Invoices.originalamount.

What I have written is:

update payables p
set p.balancedue= i.originalamount
From payables p
join invoices i on p.id=i.id
where nationalaccountcode='xxx'

But i'm getting an error. Any help? SSMS 2012, if that helps.

9000
  • 39,899
  • 9
  • 66
  • 104
  • I think you're looking for this: http://stackoverflow.com/questions/1293330/how-can-i-do-an-update-statement-with-join-in-sql – DLeh Jan 07 '14 at 20:16

1 Answers1

1

Try this...

UPDATE Payables 
    SET balancedue = i.originalamount
FROM invoices i
WHERE nationalaccountcode='xxx' AND Payables.id = i.id
user2989408
  • 3,127
  • 1
  • 17
  • 15