Home about IT Motivation Course Sales Project About Me

Wednesday, September 15, 2010

SQL script to update another table

berikut contoh script SQL Server untuk update suatu column dari tabel lain: dengan kondisi jumlah row dari data source lebih sedikit dari jumlah row dari tabel yang akan di update:

Update mpn SET EQTY_MPN = aa.quantity from (select part,quantity from vwimport ) AS aa where mpn.PN_MPN = aa.part

bila ingin quantity kolom asal dijumlah dengan quantity data updatedmaka akan menjadi sbb:


Update mpn SET EQTY_MPN = (EQTY_MPN+aa.quantity) from (select part,quantity from vwimport ) AS aa where mpn.PN_MPN = aa.part

No comments: