Query to find long running operations in SQL Server and their completion time
Below query will provide you with the stats of running operations (like Backups, Restore, DBCC operations e.t.c.), you can modify this query and add the SQL Operation you are trying to find the information about:
SELECT
session_id as SPID,
command,
a.text AS Query,
start_time,
percent_complete,
dateadd(
second,
estimated_completion_time / 1000,
getdate()
) as estimated_completion_time
FROM
sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
WHERE
r.command in (
'BACKUP DATABASE', 'RESTORE DATABASE',
'DbccFilesCompact', 'ROLLBACK',
'SELECT INTO', 'BULK INSERT', 'INSERT',
'MERGE'
)
Comments
Post a Comment