Sebastian,
Here is the SP from the database (5.1.4)
USE [mbgt]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetEventLog]
@PortalID int,
@LogTypeKey nvarchar(35),
@PageSize int,
@PageIndex int
AS
DECLARE @PageLowerBound int
DECLARE @PageUpperBound int
-- Set the page bounds
SET @PageLowerBound = @PageSize * @PageIndex
SET @PageUpperBound = @PageLowerBound + @PageSize + 1
CREATE TABLE #PageIndex
(
IndexID int IDENTITY (1, 1) NOT NULL,
LogGUID varchar(36) COLLATE database_default
)
INSERT INTO #PageIndex (LogGUID)
SELECT EventLog.LogGUID
FROM EventLog
INNER JOIN EventLogConfig
ON EventLog.LogConfigID = EventLogConfig.ID
WHERE (LogPortalID = @PortalID or @PortalID IS NULL)
AND (EventLog.LogTypeKey = @LogTypeKey or @LogTypeKey IS NULL)
ORDER BY LogCreateDate DESC
SELECT EventLog.*
FROM EventLog
INNER JOIN EventLogConfig
ON EventLog.LogConfigID = EventLogConfig.ID
INNER JOIN #PageIndex PageIndex
ON EventLog.LogGUID = PageIndex.LogGUID
WHERE PageIndex.IndexID > @PageLowerBound
AND PageIndex.IndexID < @PageUpperBound
ORDER BY
PageIndex.IndexID
SELECT COUNT(*) as TotalRecords
FROM #PageIndex