zoukankan      html  css  js  c++  java
  • SQL Server 两条数据创建时自动关联

    begin
    update a set a.sglzbbh = b.sname+'-'+convert(char(200),(1+isnull(SUBSTRING(c.glh,CHARINDEX('-', c.glh)+1, LEN(c.glh)),0))) 
    from workplan a join org_employee b on b.id = a.idowner 
    join (select aa.idowner id,max(SUBSTRING(aa.sglzbbh, CHARINDEX('-', aa.sglzbbh)+1, LEN(aa.sglzbbh))) glh 
    from workplan aa group by aa.idowner ) c on c.id = a.idowner
    where a.id = '${targetID}'
    --自动关联上周计划编号
    --自动关联上周计划编号
    update a set a.idszzb = b.id  
    from workplan a join workplan b 
    on left(a.sglzbbh,charindex('-',a.sglzbbh)-1)+'-'+convert(char(200),isnull(SUBSTRING(a.sglzbbh,CHARINDEX('-', a.sglzbbh)+1, LEN(a.sglzbbh)),0)-1) = b.sglzbbh 
    where a.id = '${targetID}'
    --自动上计划关联下周计划编号
    update b set b.idxzjh = a.id  
    from workplan a join workplan b 
    on left(a.sglzbbh,charindex('-',a.sglzbbh)-1)+'-'+convert(char(200),isnull(SUBSTRING(a.sglzbbh,CHARINDEX('-', a.sglzbbh)+1, LEN(a.sglzbbh)),0)-1) = b.sglzbbh 
    where a.id = '${targetID}'
    end
  • 相关阅读:
    codefroces 946F Fibonacci String Subsequences
    [HNOI2010]MATRIX 矩阵
    [HNOI2010]STONE取石头游戏
    [HNOI2010]PLANAR
    [HNOI2010]BUS 公交线路
    [HNOI2010]CHORUS 合唱队
    [HNOI2011]赛车游戏
    [HNOI2011]数矩形
    [HNOI2012]与非
    [BZOJ4200][NOI2015]小园丁与老司机
  • 原文地址:https://www.cnblogs.com/RainHouse/p/10844754.html
Copyright © 2011-2022 走看看