サンプル データについては、以下のスクリーン キャップを参照してください。これらのデータを正規化すると、データに関する限り同じことを意味するこれらの類似のコードが見つかりました。primarycode
右側の s が左側の s に更新されるようにテーブルを更新しようとしています
これらの値を見つけるために使用したクエリ:
select *
from icd
inner join icd as i2 on i2.primarycodetext=icd.primarycodetext
and i2.primarycode <> icd.primarycode
where icd.primarycode like '%0'
私が試した更新クエリ。
update icd
set icd.primarycode=i2.primarycode
from
(
select *
from icd
inner join icd as i2 on i2.primarycodetext=icd.primarycodetext
and i2.primarycode <> icd.primarycode
where icd.primarycode like '%0'
)t
受信したエラー:Msg 8156, Level 16, State 1, Line 12
The column 'primarycode' was specified multiple times for 't'.
編集: このテーブルの 2 つの列のみが primarycode と primarycodetext です