1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-05 11:42:22 -05:00
bitwarden/src/Sql/dbo/Stored Procedures/Event_ReadPageByUserId.sql
2017-12-18 23:15:16 -05:00

24 lines
582 B
Transact-SQL

CREATE PROCEDURE [dbo].[Event_ReadPageByUserId]
@UserId UNIQUEIDENTIFIER,
@StartDate DATETIME2(7),
@EndDate DATETIME2(7),
@BeforeDate DATETIME2(7),
@PageSize INT
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[EventView]
WHERE
[Date] >= @StartDate
AND (@BeforeDate IS NOT NULL OR [Date] <= @EndDate)
AND (@BeforeDate IS NULL OR [Date] < @BeforeDate)
AND [OrganizationId] IS NULL
AND [ActingUserId] = @UserId
ORDER BY [Date] DESC
OFFSET 0 ROWS
FETCH NEXT @PageSize ROWS ONLY
END