Thursday, October 24, 2013

Get Times for CRM Import Jobs

This script will give you the times for CRM import jobs that have been run on your system.

--Shows all import records and the amount of time they took
SELECT [Name], [StartedOn], [CompletedOn],
DATEDIFF(MINUTE, [StartedOn], [CompletedOn]) AS [Diff In Minutes]
FROM [Default_MSCRM].[dbo].[AsyncOperationBase]
WHERE OperationType IN (3,4,5) --OperationType 3,4,5 are the ones which relate to imports


--Shows total number of minutes for all imports
SELECT SUM(DATEDIFF(MINUTE, [StartedOn], [CompletedOn])) AS [Total Diff In Minutes]
FROM [Default_MSCRM].[dbo].[AsyncOperationBase]
WHERE OperationType IN (3,4,5)


--Shows total number of hours for all imports
SELECT SUM(DATEDIFF(MINUTE, [StartedOn], [CompletedOn])) /60 AS [Total Diff In Hours]
FROM [Default_MSCRM].[dbo].[AsyncOperationBase]
WHERE OperationType IN (3,4,5)

No comments: