兩個資料結構完全相同,只是名字不同的資料庫A,B中,都有同名表 transact
表中有trn_amt,trn_id,trn_dt(日期).
我現在想把A庫中trn_dt日期小于等于2020-08-31的trn_amt值,替換掉B庫中trn_id相同的trn_amt的值。
uj5u.com熱心網友回復:
在線等~~~~~~~
uj5u.com熱心網友回復:
--用A庫的trn_amt值去替換B庫對應的trn_amt值
--前提:trn_id 具有唯一性
update
b
set b.trn_amt = a.trn_amt
from A.dbo.transact a , B.dbo.transact b
where a.trn_id = b.trn_id
and a.trn_dt < ='2020-08-31'
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/197612.html
標籤:基礎類
上一篇:字串連接后輸出的問題
下一篇:sql陳述句優化
