查找担保圈-step6-对被包含过的组进行清理,只保留未被包含过的组

 1 USE [test]
 2 GO
 3 /****** Object:  StoredProcedure [dbo].[p04_get_groupno_cleared]    Script Date: 2019/7/8 15:03:02 ******/
 4 SET ANSI_NULLS ON
 5 GO
 6 SET QUOTED_IDENTIFIER ON
 7 GO
 8 ALTER PROC [dbo].[p04_get_groupno_cleared]
 9 AS
10 --s4,对被包含过的组进行清理,只保留未被包含过的组
11 BEGIN
12     IF OBJECT_ID(N'dbo.t04_get_groupno_cleared') IS NOT NULL
13         DROP TABLE dbo.t04_get_groupno_cleared;
14 
15     SELECT iinclude_groupno
16     INTO dbo.t04_get_groupno_cleared
17     FROM dbo.t03_get_groupno --只存在于包含列(include),不存在与被包含列的(ibeincluded_groupno)的组号
18     EXCEPT
19     SELECT ibeincluded_groupno
20     FROM dbo.t03_get_groupno;
21     ALTER TABLE dbo.t04_get_groupno_cleared
22     ALTER COLUMN iinclude_groupno INT NOT NULL;
23     ALTER TABLE dbo.t04_get_groupno_cleared
24     ADD
25         PRIMARY KEY (iinclude_groupno);
26 END;

 

posted on 2019-07-08 15:04  hold_on_up  阅读(108)  评论(0编辑  收藏  举报