• SQLSERVER初始化机构path


    代码如下:

    IF OBJECT_ID('tempdb..#testOU') IS NOT NULL DROP TABLE #testOU;
    WITH oulist as
    (
    select CAST('0001' AS VARCHAR(max)) AS codes,a.* from dbo.Org a WHERE a.PlatformOrgId = '00000000000000000000000000000001' 
        union all
    select 
    w.codes
    +  cast( ROW_NUMBER() over (order by a.sort) /1000 as  varchar(max)) 
    +  cast( ROW_NUMBER() over (order by a.sort) % 1000 /100 as  varchar(max))
    +  cast( ROW_NUMBER() over (order by a.sort) %1000 % 100 /10 as  varchar(max)) 
    +  cast( ROW_NUMBER() over (order by a.sort) %1000 % 100 %10 as  varchar(max)) 
    
    codes,
     a.* from  dbo.Org a 
        join oulist w on a.ParentID = w.PlatformOrgId 
    )
    SELECT *,len(Codes)/4-1 AS oLevel into #testOU FROM oulist order by code
    
    update dbo.Org SET Org.OrgPath = b.codes from   dbo.Org o inner join #testOU  b on o.PlatformOrgId = b.PlatformOrgId 
    
    IF OBJECT_ID('tempdb..#testOU') IS NOT NULL DROP TABLE #testOU;
  • 相关阅读:
    SpringMvc---Ant通配符
    mybatis 数据库语句
    shiro 静态页面资源不显示 解决方案
    http错误汇总
    关于代码质量与逻辑
    shiro 过滤属性的意义
    java思维导图
    E
    LCIS HDU
    E
  • 原文地址:https://www.cnblogs.com/no27/p/14153472.html
Copyright © 2020-2023  润新知