UPDATE ADDRESS
SET ADDRESS.LATITUDE = b.latitude,
ADDRESS.LONGITUDE= b.LONGITUDE
FROM POSTAL_CODE_LOOKUP b
WHERE ADDRESS.postal_cd = b.POSTALCODE
AND (address.LATITUDE != b.LATITUDE OR address.LONGITUDE !=b.LONGITUDE)
11:20:23 [BEGIN - 2454 row(s), 0.437 secs] Command processed
11:20:23 [BEGIN - 2454 row(s), 0.437 secs] Command processed
... 2 statement(s) executed, 4908 row(s) affected, exec/fetch time: 0.874/0.000 sec [2 successful, 0 warnings, 0 errors]
執行更新後,我運行下面的SQL並獲取2454條記錄。更新SQL Server兩條語句
select
a1.POSTAL_CD, b.POSTALCODE,
a1.LATITUDE, b.LATITUDE,
a1.LONGITUDE, b.LONGITUDE
from
ADDRESS a1, POSTAL_CODE_LOOKUP b
where
a1.postal_cd = b.postalcode
and (a1.LATITUDE != b.LATITUDE or a1.LONGITUDE != b.LONGITUDE);
是的我已經犯了,記錄沒有改變。我不明白爲什麼更新被解讀爲2條語句。我不明白爲什麼它沒有更新。
我應該如何編寫此更新聲明?
也許'Address'有'UPDATE'觸發器。 –
您不應該再使用舊式連接:[舊式連接](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old -style-joins.aspx) – NickyvV
奇怪的問題,但你確定你已經正確地標記了問題嗎?那些輸出消息不像我熟悉的[tag:sql-server]。 –