Skip to content

Instantly share code, notes, and snippets.

@bvanskiver
Last active December 17, 2023 05:59
Show Gist options
  • Save bvanskiver/1a97607bd432965493e75a689b3b8f5b to your computer and use it in GitHub Desktop.
Save bvanskiver/1a97607bd432965493e75a689b3b8f5b to your computer and use it in GitHub Desktop.
select r.session_id as SPID, r.command, r.[status],
FORMAT(r.percent_complete, 'n0') + '%' as percent_complete,
FORMAT(r.start_time, 'MM/dd/yyyy hh:mm:ss tt') as start_time,
FORMAT(r.total_elapsed_time / 3600000 % 60, '00') + ':' + FORMAT(r.total_elapsed_time / 60000 % 60, '00') + ':' + FORMAT(r.total_elapsed_time / 1000 % 60, '00') as elapsed_time,
FORMAT(DATEADD(MILLISECOND, r.estimated_completion_time, GETDATE()), 'MM/dd/yyyy hh:mm:ss tt') as estimated_completion_time,
FORMAT(r.estimated_completion_time / 3600000 % 60, '00') + ':' + FORMAT(r.estimated_completion_time / 60000 % 60, '00') + ':' + FORMAT(r.estimated_completion_time / 1000 % 60, '00') as estimated_time_remaining,
FORMAT((r.total_elapsed_time + r.estimated_completion_time) / 3600000 % 60, '00') + ':' + FORMAT((r.total_elapsed_time + r.estimated_completion_time) / 60000 % 60, '00') + ':' + FORMAT((r.total_elapsed_time + r.estimated_completion_time) / 1000 % 60, '00') as estimated_total_time
from sys.dm_exec_requests r
where r.percent_complete > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment