您的位置:金沙游乐场85155 > 大数据库 > SqlServer递归查询金沙85155登入:

SqlServer递归查询金沙85155登入:

发布时间:2019-10-02 09:54编辑:大数据库浏览(82)

     1 DECLARE @ParentId NVARCHAR(36);
     2 SET @ParentId = '078499bf-dedd-b293-4653-7bf6a2e54cbb';
     3 
     4 WITH [Temp] AS
     5 (
     6     SELECT [A].* FROM [dbo].[Contacts] A WHERE [A].[ParentID] = @ParentId AND [A].[IsDefault] = 1
     7     UNION ALL
     8     SELECT [A].* FROM [dbo].[Contacts] A INNER JOIN [Temp] B ON A.[ParentID] = B.[ObjectID] AND [A].[IsDefault] = 1
     9 )
    10 SELECT * FROM [Temp] ORDER BY [Temp].[GlobalSort] ASC;
    

    本文由金沙游乐场85155发布于大数据库,转载请注明出处:SqlServer递归查询金沙85155登入:

    关键词: