查找擔保圈-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;
相關文章
相關標籤/搜索