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

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetEntriesByLastVersion
  @LastVersionId Int, @PortalId Int
AS

SELECT {databaseOwner}{objectQualifier}DMX_Entries.*
FROM {databaseOwner}{objectQualifier}DMX_Entries
WHERE ((({objectQualifier}DMX_Entries.LastVersionId)=@LastVersionId) AND (({objectQualifier}DMX_Entries.PortalId)=@PortalId))

GO

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

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetCollectionContents
  @AllVersions Bit, @ParentId Int, @PortalId Int, @UserId Int
AS

SELECT {databaseOwner}{objectQualifier}DMX_Entries.*, LTrim(RTrim({objectQualifier}Users.FirstName+' '+{objectQualifier}Users.LastName)) AS FullName, {databaseOwner}{objectQualifier}DMX_Extensions.Name, {databaseOwner}{objectQualifier}DMX_Extensions.Icon16, UserSubs.id, UserSubs.LastAccess
FROM (({objectQualifier}Users INNER JOIN {databaseOwner}{objectQualifier}DMX_Entries ON {databaseOwner}{objectQualifier}Users.UserID = {databaseOwner}{objectQualifier}DMX_Entries.UserId) LEFT JOIN {databaseOwner}{objectQualifier}DMX_Extensions ON {databaseOwner}{objectQualifier}DMX_Entries.EntryType = {databaseOwner}{objectQualifier}DMX_Extensions.ExtensionKey) LEFT JOIN (SELECT * FROM {databaseOwner}{objectQualifier}DMX_Subscriptions WHERE {databaseOwner}{objectQualifier}DMX_Subscriptions.UserId=@UserId) AS UserSubs ON {databaseOwner}{objectQualifier}DMX_Entries.EntryId = UserSubs.EntryId
WHERE (((({objectQualifier}DMX_Entries.EntryId)=([{objectQualifier}DMX_Entries].[LastVersionId])) OR (@AllVersions=1))
AND (({objectQualifier}DMX_Entries.CollectionId)=@ParentId) 
AND (({objectQualifier}DMX_Entries.PortalId)=@PortalId))

GO

