zoukankan      html  css  js  c++  java
  • merge into 笔记

    1 IF EXISTS (SELECT 1 FROM sys.types t
               join sys.schemas s on t.schema_id=s.schema_id
               and t.name='tp_AICMonthlyWarrantData' and s.name='MIR')
       DROP TYPE MIR.tp_AICMonthlyWarrantData
    GO

    CREATE TYPE MIR.tp_AICMonthlyWarrantData AS TABLE
    (
        SecId              CHAR(10) NOT NULL,
        EffectiveDate      DATE     NOT NULL,
        WarrantIssued      INT      NULL,
        WarrantExercised   INT  NULL,
        WarrantsCancelled  INT  NULL,
        WarrantsExpired    INT  NULL,
        Outstanding        BIGINT NULL,
        Note               NVARCHAR(500) NULL
    )
    GO
    GRANT EXECUTE ON TYPE::MIR.tp_AICMonthlyWarrantData TO PUBLIC
    GO

    2  MERGE INTO OperationData.MIR.AICMonthlyWarrantData a
            USING @p_warrantTable b
            ON a.SecId=b.SecId and a.EffectiveDate=b.EffectiveDate
            WHEN MATCHED THEN UPDATE
              SET a.Issued=b.WarrantIssued,
                  a.Exercised=b.WarrantExercised,
                  a.Repurchased=b.WarrantsCancelled,
                  a.Expired=b.WarrantsExpired,
                  a.Outstanding=b.Outstanding,
                  a.Note=b.Note
            WHEN NOT MATCHED THEN
            INSERT (SecId,EffectiveDate,Issued,Exercised,Repurchased,Expired,Outstanding,Note,LastUpdate)
            VALUES(b.SecId,b.EffectiveDate,b.WarrantIssued,b.WarrantExercised,b.WarrantsCancelled,b.WarrantsExpired,
            b.Outstanding,b.Note,getdate());

            MERGE INTO OperationData.MIR.AICMonthlyCovertibleData a
            USING @p_convertibleTable b
            ON a.SecId=b.SecId and a.EffectiveDate=b.EffectiveDate
            WHEN MATCHED THEN UPDATE
              SET a.Issued=b.ConvertibleIssued,
                  a.Repurchased=b.ConvertibleRepurchased,
                  a.Converted=b.ConvertibleConverted,
                  a.Redeemed=b.ConvertibleRedeemed,
                  a.Outstanding=b.Outstanding,
                  a.Note=b.Note,
                  a.ConvertibleTotalValue=b.ConvertibleConvertibleTotalValue,
                  a.ConvertibleFairValue=b.ConvertibleConvertibleFairValue
            WHEN NOT MATCHED THEN
            INSERT (SecId,EffectiveDate,Issued,Repurchased,Converted,Redeemed,Outstanding,Note,
            ConvertibleTotalValue,ConvertibleFairValue,LastUpdate)
            VALUES(b.SecId,b.EffectiveDate,b.ConvertibleIssued,b.ConvertibleRepurchased,b.ConvertibleConverted,b.ConvertibleRedeemed,
            b.Outstanding,b.Note,b.ConvertibleConvertibleTotalValue,b.ConvertibleConvertibleFairValue,getdate());

  • 相关阅读:
    高并发、高性能、高可用
    性能优化 = 改改代码?
    高级开发必须理解的Java中SPI机制
    java性能优化的50个细节(珍藏版)
    Java API 设计清单
    QString与QByteArray互相转换的方法
    QT 托盘 hover事件捕捉
    qt捕获全局windows消息
    前端开发树形插件带来的烦恼(一)
    靠谱的div引入任何外链内容
  • 原文地址:https://www.cnblogs.com/mibing/p/8609787.html
Copyright © 2011-2022 走看看