SQL Server – Job Completion Status

One of the often-used scripts that DBAs keep on hand must be the one that shows how far a session has advanced. The statement below is quite helpful when seeking to estimate the percentage of backup or restore processes that have been finished.

SELECT Session_Id,
Reads, Writes,
Cpu_Time,
Logical_Reads,
Total_Elapsed_Time,
Blocking_Session_Id,
Percent_Complete,
Command,
(SELECT text FROM sys.dm_exec_sql_text(sql_handle)) AS Text
FROM sys.dm_exec_requests
WHERE session_id = <SessionID>

As stated above, this command will let you know the percentage of completion of the session whether it is a backup process or restoration.

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s