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());

  • 相关阅读:
    Linux下查看文件和文件夹大小的df和du命令(链接)
    路由的原理和作用[赛迪网]
    select 好用插件
    如何启动/停止/重启MySQL
    Spirng quartz 整合
    String,StringBuffer与StringBuilder的区别
    如何给input[file]定义cursor
    dns简介
    浏览器高级对象
    shell 学习文章列表
  • 原文地址:https://www.cnblogs.com/mibing/p/8609787.html
Copyright © 2011-2022 走看看