• SQL语句实现递归


            

    1 WITH TempDeptment ([ID],[PID],[DeptName],[Conjunction]) AS
    2 (
    3     SELECT [ID],[PID],[DeptName], CAST([DeptName] AS Nvarchar(1000)) FROM [dbo].[Deptment] WHERE [PID] = 0
    4     UNION ALL
    5     SELECT d.[ID], d.[PID], d.[DeptName], CAST(([Conjunction] + N'/' + d.[DeptName]) AS Nvarchar(1000))    FROM TempDeptment AS td,[dbo].[Deptment] AS d WHERE td.[ID] = d.[PID]
    6 )
    7 SELECT [ID], [Conjunction] FROM TempDeptment

  • 相关阅读:
    HDU 6043
    HDU 6033
    HDU 6041
    HDU 6050
    HDU 6053
    HDU 6055
    HDU 6045
    HDU 6044
    HDU 6040
    ZUFE 1035 字符宽度编码(字符串)
  • 原文地址:https://www.cnblogs.com/it-bobo/p/3860761.html
Copyright © 2020-2023  润新知