-- ================================================ -- 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 InitialConjuntiveConditions AS BEGIN --SET NOCOUNT ON; DECLARE @con1 VARCHAR(50); DECLARE @con2 VARCHAR(50); DECLARE conditions1 CURSOR FOR SELECT distinct id FROM AtomicConditions DECLARE conditions2 CURSOR FOR SELECT distinct id FROM AtomicConditions OPEN conditions1 FETCH NEXT FROM conditions1 into @con1; DELETE FROM ComplexConditions; WHILE @@fetch_status = 0 BEGIN OPEN conditions2 FETCH NEXT FROM conditions2 into @con2; --IF @con1<>@con2 -- INSERT INTO ComplexConditions (condition1, condition2, type) VALUES (@con1, @con2, 'conjuntive'); WHILE @@fetch_status = 0 BEGIN IF (((@con1<>@con2) AND ((SELECT COUNT(*) FROM ComplexConditions WHERE condition1=@con2 AND condition2=@con1)<>1)) AND ((@con1<>@con2) AND ((SELECT COUNT(*) FROM ComplexConditions WHERE condition2=@con2 AND condition1=@con1)<>1))) INSERT INTO ComplexConditions (condition1, condition2, type) VALUES (@con1, @con2, 'conjuntive'); FETCH NEXT FROM conditions2 into @con2; END; CLOSE conditions2; FETCH NEXT FROM conditions1 into @con1; END; CLOSE conditions1; DEALLOCATE conditions1; DEALLOCATE conditions2; EXEC RemoveDuplicatesFromComplexConditions; END GO