-- ================================================ -- Template generated from Template Explorer using: -- Create Procedure (New Menu).SQL -- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. -- -- This block of comments will not be included in -- the definition of the procedure. -- ================================================ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE PROCEDURE InitialL2ConjuntiveConditions AS BEGIN --SET NOCOUNT ON; DECLARE @con1 BIGINT; DECLARE @con2 BIGINT; DECLARE conditions1 CURSOR FOR SELECT distinct id FROM ComplexConditions DECLARE conditions2 CURSOR FOR SELECT distinct id FROM ComplexConditions OPEN conditions1 FETCH NEXT FROM conditions1 into @con1; DELETE FROM ComplexL2Conditions; WHILE @@fetch_status = 0 BEGIN OPEN conditions2 FETCH NEXT FROM conditions2 into @con2; IF @con1<>@con2 INSERT INTO ComplexL2Conditions (condition1, condition2, type) VALUES (@con1, @con2, 'conjuntive'); WHILE @@fetch_status = 0 BEGIN FETCH NEXT FROM conditions2 into @con2; IF ((@con1<>@con2) AND ((SELECT COUNT(*) FROM ComplexL2Conditions WHERE condition1=@con2 AND condition2=@con1)<>1)) INSERT INTO ComplexL2Conditions (condition1, condition2, type) VALUES (@con1, @con2, 'conjuntive'); END; CLOSE conditions2; FETCH NEXT FROM conditions1 into @con1; END; CLOSE conditions1; DEALLOCATE conditions1; DEALLOCATE conditions2; EXEC RemoveDuplicatesFromComplexL2Conditions; END GO