这是进行此更新的正确方法,是这样吗:
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 <> '--'