IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_EmptyRecycleBin') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_EmptyRecycleBin
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_EmptyRecycleBin

AS

DELETE 
 {databaseOwner}{objectQualifier}DMX_Entries
FROM 
 {databaseOwner}{objectQualifier}DMX_Entries,
 {databaseOwner}{objectQualifier}DMX_Entries AS E
WHERE
 ({objectQualifier}DMX_Entries.LastVersionId = E.EntryId)
 AND
 (((E.LastVersionId=E.[EntryId]) AND (E.Deleted = 1))
 OR
 (({objectQualifier}DMX_Entries.EntryId <> {databaseOwner}{objectQualifier}DMX_Entries.LastVersionId)
 AND ({objectQualifier}DMX_Entries.Deleted=1)))

GO


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetRecycleBinFileList') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetRecycleBinFileList
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetRecycleBinFileList

AS

SELECT 
 {databaseOwner}{objectQualifier}DMX_Entries.Entry
FROM 
 {databaseOwner}{objectQualifier}DMX_Entries,
 {databaseOwner}{objectQualifier}DMX_Entries AS E
WHERE
 ({objectQualifier}DMX_Entries.LastVersionId = E.EntryId)
 AND
 (((E.LastVersionId=E.[EntryId]) AND (E.Deleted = 1))
 OR
 (({objectQualifier}DMX_Entries.EntryId <> {databaseOwner}{objectQualifier}DMX_Entries.LastVersionId)
 AND ({objectQualifier}DMX_Entries.Deleted=1)))

GO
