zoukankan      html  css  js  c++  java
  • SqlServer 游标生成主外键关联表insert语句

    declare @RR nvarchar(max)
    declare @PCR nvarchar(max)
    declare @RequestRecordId bigint
    declare my_cursor cursor
    for (select a.RequestRecordId from [dbo].[CUP_RequestRecord] a inner join [dbo].[CUP_POSCreditResult] b on b.RequestRecordId=a.RequestRecordId)
    open my_cursor
    fetch next from my_cursor into @RequestRecordId
    while @@fetch_status = 0
        begin
            select @RR='insert into [dbo].[CUP_RequestRecord] select '''+SourceRequest+''',N'''+ApplicationNumber+''',N'''+CONVERT(varchar(100), ApplicationDatetime, 25)+''',N'''+CustomerName+''',N'''+IdentifyType+''',N'''+IdentifyNumber+''',N'''+BankCardNo+''',N'''+MobilePhone+''',N'''+IssueCountry+''',N'''+[Role]+''',N'''+QueryEmployee+''',N'''+QueryReason+''',N'''+ReqDataJson+''',N'''+isnull(ReqSensDataJson,'')+''',N'''+''',N'''+cast(ReqDate as varchar(MAX))+''',N'''+RespCode+''',N'''+RespMsg+''',N'''+''',N'''+''',N'''+case when RespCombiLabelsJson is null then '' else cast(RespCombiLabelsJson as varchar(max)) end+''',N'''+CONVERT(varchar(100), RespDate, 25)+''',N'''+CONVERT(varchar(100), CreateDate, 25)+''',N'''+isnull(EcmStorageStatus,'')+''',N'''+isnull(EcmStorageUrl,'')+'''' from [dbo].[CUP_RequestRecord] where RequestRecordId=@RequestRecordId
            select @PCR='insert into [dbo].[CUP_POSCreditResult] select @@IDENTITY'+','+cast(TotalExpenditureAmt as varchar(MAX))+','+cast(VIPCardNumber as varchar(MAX))+','+cast(HaveHouse as varchar(MAX))+','+cast(HaveCar as varchar(MAX))+','+cast(HaveChild as varchar(MAX))+',N'''+isnull(OneYearExpenditureFirstCity,'')+''',N'''+isnull(OneYearExpenditureSecondCity,'')+''',N'''+isnull(OneYearExpenditureThirdCity,'')+''','+cast(TotallFinancialAmt as varchar(MAX))+','+cast(GinkgoScore as varchar(MAX))+','+cast(AntiFraudScore as varchar(MAX))+','+cast(GoldCardCount as varchar(MAX))+','+cast(TitaniumCardCount as varchar(MAX))+','+cast(PlatinumCardCount as varchar(MAX))+','+cast(DiamondCardCount as varchar(MAX)) from [dbo].[CUP_POSCreditResult] where RequestRecordId=@RequestRecordId
            print @RR
            print @PCR
            set @RR=''
            set @PCR=''
            fetch next from my_cursor into @RequestRecordId
        end
    close my_cursor
    deallocate my_cursor
    go
  • 相关阅读:
    nginx 日志之 error_log
    ssl 原理简介
    nginx 配置ssl
    自建 ca 及使用 ca 颁发证书
    nginx 访问控制之 认证
    nginx 访问控制之 限速
    nginx 访问控制之 http_referer
    nginx 访问控制之 user_agent
    nginx 访问控制之 request_uri
    nginx 访问控制之 document_uri
  • 原文地址:https://www.cnblogs.com/hofmann/p/12205033.html
Copyright © 2011-2022 走看看