Wednesday, March 20, 2024

.::: Check Status Backup & Restore Progress in % Percent MSSQL SQL Server :::.


A. Backup

1. Query 1

SELECT @@servername as ServerName, command, percent_complete,total_elapsed_time, estimated_completion_time, start_time
  FROM sys.dm_exec_requests
  WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')


2. Query 2


SELECT @@servername as Servername,
    session_id AS SPID,
    command,
    s.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) s
WHERE
    r.command LIKE 'BACKUP%'
    AND r.percent_complete > 0;

 

B. Restore


1. Query 1    

SELECT @@servername as ServerName, command, percent_complete,total_elapsed_time, estimated_completion_time, start_time
  FROM sys.dm_exec_requests
  WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')

 
2. Query 2

SELECT @@servername as Servername,
    session_id AS SPID,
    command,
    s.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) s
WHERE
    r.command LIKE 'RESTORE%'
    AND r.percent_complete > 0;

 

No comments:

Post a Comment

Popular Posts