IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[AKUZ].[sp_DropExpiredIheClinicalDocumentEvent]') AND type in (N'P', N'PC'))
DROP PROCEDURE [AKUZ].[sp_DropExpiredIheClinicalDocumentEvent]
GO

 CREATE PROCEDURE AKUZ.sp_DropExpiredIheClinicalDocumentEvent
 AS 
 BEGIN

	DELETE FROM [AKUZ].[T_IHE_CLINICALDOCUMENT_EVENT]
	WHERE 
		[Status] = 2
		and [EventTime] < DATEADD(DAY, -30, getdate())

 END;