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