0
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;
4

1 回答 1

0

尽量不要访问整个对象dimSccservertbl.

例如替换

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
于 2013-11-11T12:59:12.110 回答