MERGE dimS AS T
USING ccservertbl AS S
ON (T.iAID = S.ServerID) OR (T.iAID = S.SID)
WHEN NOT MATCHED BY TARGET
THEN INSERT (
iAID,
ConfigItemName,
PropertyName,
NetWorkDomainName,
DataCenterTLA,
RetireValueIND,
AssetOnlyInd,
LastUpdatedDtim,
ODataServerID)
VALUES (
S.SID,
S.Name,
S.PropertyDimension,
S.NetworkDomain,
S.datacenterCode,
S.RetiredvalueInd,
S.IsAssetonly,
S.Modified,
S.ID)
WHEN MATCHED
THEN UPDATE
SET T.ConfigItemName = S.Name,
T.PropertyName = S.PropertyDimension,
T.NetWorkDomainName = S.NetworkDomain,
T.DataCenterTLA = S.datacenterCode,
T.RetireValueIND = S.RetiredvalueInd,
T.AssetOnlyInd = S.IsAssetonly,
T.LastUpdatedDtim = S.Modified,
T.ODataServerID = S.ID;
答案 0 :(得分:0)
尽量不要访问整个对象dimS
和ccservertbl
。
例如替换
MERGE dimS AS T
USING ccservertbl AS S
与
;WITH TargetTable AS (
SELECT *
FROM dimS
WHERE <some slicing clause>
), SourceTable AS (
SELECT *
FROM ccservertbl
WHERE <some slicing clause>
)
MERGE TargetTable AS T
USING SourceTable AS S