Time Remaining for SQL task/ Percentage Compelte (Backup/ Restore)

When we take a backup or restore a database using command, we always like to track the progress. This SQL script helps you to do the same!

select command, sp.loginame, hostname, start_time, er.status 
,CAST(total_elapsed_time/1000.0 AS NUMERIC(8,2)) AS [Elapsed Seconds]
,CAST(estimated_completion_time/1000.0/60.0 AS NUMERIC(8,2)) AS [ETA Min]
,CAST(estimated_completion_time/1000.0/60.0/60.0 AS NUMERIC(8,2)) AS [ETA Hours]
,CAST(percent_complete AS NUMERIC(8,2)) AS [Percent Complete]
from sys.dm_exec_requests er 
join sys.sysprocesses sp on sp.spid = er.session_id
where session_id > 50 -- Replace with >50 with =SPID for actual task status you want to track 
Advertisements
This entry was posted in Script, SQL, SQL Query and tagged , , . Bookmark the permalink.

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 )

Google+ photo

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

Connecting to %s