查找担保圈-step3-获取担保圈路径

 1 USE [test]
 2 GO
 3 /****** Object:  StoredProcedure [dbo].[p01_get_group_path]    Script Date: 2019/7/8 14:40:47 ******/
 4 SET ANSI_NULLS ON
 5 GO
 6 SET QUOTED_IDENTIFIER ON
 7 GO
 8 ALTER PROC [dbo].[p01_get_group_path]
 9 AS
10 --s1,获取担保圈路径
11 IF OBJECT_ID(N'dbo.t01_get_group_path') IS NOT NULL
12     DROP TABLE dbo.t01_get_group_path;
13 
14 SELECT t.full_path,
15        t.nlevel,
16        ROW_NUMBER() OVER (ORDER BY t.full_path) AS groupno
17 INTO dbo.t01_get_group_path
18 FROM
19 (
20     SELECT DISTINCT
21            b.full_path,
22            b.nlevel
23     FROM [dbo].[dbgx] AS a
24         CROSS APPLY [dbo].[f_findrecycle](a.KHMC, 10) AS b
25 --WHERE     a.KHMC IN ( '山东郓城卡德维润滑油有限公司', '郓城惠达化纤制品有限公司',
26 --                      '郓城县久隆塑料制品有限公司', '郓城海鹏鞋业有限公司', '郓城昌顺机械有限公司',
27 --                      '郓城恩银机械有限公司' )
28 ) AS t;

 

posted on 2019-07-08 14:42  hold_on_up  阅读(117)  评论(0编辑  收藏  举报