この更新を行う正しい方法は次のとおりです。
UPDATE [log].codesEntered
SET [log].codesEntered.countrycode =
(SELECT [user].[profile].countryCode
FROM [user].[profile]
INNER JOIN [log].codesEntered
ON [log].codesEntered.userid = [user].[profile].userid
WHERE [log].codesEntered.countryCode <> [user].[profile].countryCode
AND [log].codesEntered.campid = @campid
AND [log].codesEntered.portalid = @portalid
AND [user].[profile].countryCode <> ''
AND [user].[profile].countryCode <> '--')
またはこの方法:
UPDATE [log].codesEntered
SET [log].codesEntered.countrycode = [user].[profile].countryCode
FROM [log].codesEntered
INNER JOIN [user].[profile]
ON [log].codesEntered.userid = [user].[profile].userid
WHERE [log].codesEntered.countryCode <> [user].[profile].countryCode
AND [log].codesEntered.campid = @campid
AND [log].codesEntered.portalid = @portalid
AND [user].[profile].countryCode <> ''
AND [user].[profile].countryCode <> '--'