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

  • 相关阅读:
    Scrapy抓取Quotes to Scrape
    pyspider爬取TripAdvisor
    [转]Python爬虫框架--pyspider初体验
    使用代理处理反爬抓取微信文章
    控制流程语句
    【bzoj3029】守卫者的挑战 概率dp
    【bzoj4994】[Usaco2017 Feb]Why Did the Cow Cross the Road III 树状数组
    【bzoj4952】[Wf2017]Need for Speed 二分
    【bzoj5047】空间传送装置 堆优化Dijkstra
    【bzoj5055】膜法师 离散化+树状数组
  • 原文地址:https://www.cnblogs.com/mibing/p/8609787.html
Copyright © 2011-2022 走看看