Analysis-Services/AsPartitionProcessing/AsPartitionProcessing.ConfigurationLogging/dbo/Stored Procedures/usp_LastProcessingLogs.sql
Christian Wade 46a066fa13 1400 v3
2017-04-18 18:48:52 -07:00

17 lines
507 B
Transact-SQL

CREATE PROC [dbo].[usp_LastProcessingLogs]
@ExecutionCount tinyint = 1,
@ErrorsOnly bit = 0
AS
SELECT --l.ExecutionID,
l.[LogDateTime],
l.[Message]
FROM [dbo].[ProcessingLog] l
INNER JOIN
( SELECT TOP (@ExecutionCount) [ExecutionID], MAX([LogDateTime]) [MaxLogDateTime]
FROM [dbo].[ProcessingLog]
GROUP BY ExecutionID
ORDER BY [MaxLogDateTime] DESC
) dt ON l.ExecutionID = dt.ExecutionID
WHERE @ErrorsOnly = 0 OR (@ErrorsOnly = 1 AND l.MessageType = 'Error')
ORDER BY [LogDateTime]