0

enter image description here

My mainTable has column primaryCode. These codes are incorrect and need to be updated based on the updateCodes table. The incorrect codes are in the column primaryCode on mainTable and primaryCode on the updateCodes table. The descrip column is the correct version. Since I'm not sure how rollback works, below is my query for fixing the problem; I think it's right, but not sure.

edit: There are many more codes in my mainTable than these. These are just the ones that need to be updated. I don't know if that will affect the query or not.

update mainTable
set mainTable.primaryCode=update.descrip
from mainTable
inner join updateCodes on mainTable.primaryCode=updateCodes.descrip
4

1 回答 1

1

像这样的东西怎么样:

UPDATE MainTable SET MainTable.primaryCode = UpdateCodes.descrip
FROM MainTable
INNER JOIN UpdateCodes 
ON MainTable.primaryCode = UpdateCodes.primaryCode

加入“错误”的值以获得更新的正确值......

于 2012-06-08T15:38:50.667 回答