-- ================================================ -- 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 RemoveDuplicatesFromAtomicConditions -- Add the parameters for the stored procedure here AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; IF ((SELECT count(name) FROM sys.tables WHERE name='holdkey')=1) DROP TABLE holdkey; IF ((SELECT count(name) FROM sys.tables WHERE name='holddups')=1) DROP TABLE holddups; SELECT attribute1, attribute2, col3=count(*) INTO holdkey FROM AtomicConditions GROUP BY attribute1, attribute2 HAVING count(*) > 1 SELECT DISTINCT AtomicConditions.* INTO holddups FROM AtomicConditions, holdkey WHERE AtomicConditions.attribute1 = holdkey.attribute1 AND AtomicConditions.attribute2 = holdkey.attribute2; --SELECT attribute1, attribute2, count(*) --FROM holddups --GROUP BY attribute1, attribute2; DELETE AtomicConditions FROM AtomicConditions, holdkey WHERE AtomicConditions.attribute1 = holdkey.attribute1 AND AtomicConditions.attribute2 = holdkey.attribute2; INSERT AtomicConditions SELECT distinct attribute1, attribute2 FROM holddups; IF ((SELECT count(name) FROM sys.tables WHERE name='holdkey')=1) DROP TABLE holdkey; IF ((SELECT count(name) FROM sys.tables WHERE name='holddups')=1) DROP TABLE holddups; --SELECT * FROM AtomicConditions; END GO