Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

SQL Process % Complete

By Mehernosh,

If you wanted to find out (SQL Server 2005 and onwards or with compatibility modes of 90 and higher) how long a particular Backup or restore on a database was taking or elapsed time, then the following SQL can help:
(I know the SQL GUI will show this in increments of 10% and all... but sometimes we just want to know how long it has taken and what percent it is currently at )

USE MASTER
--
SELECT SESSION_ID, '[' + CAST(DATABASE_ID AS VARCHAR(10)) + '] ' + DB_NAME(DATABASE_ID) AS [DATABASE],
PERCENT_COMPLETE, START_TIME, STATUS, COMMAND,
DATEADD(MS, ESTIMATED_COMPLETION_TIME, GETDATE()) AS ESTIMATED_COMPLETION_TIME, CPU_TIME
FROM SYS.DM_EXEC_REQUESTS
--Apply this Where Clause Filter if you need to check specific events such as Backups, Restores, Index et al.
WHERE COMMAND LIKE '%BACKUP%' OR COMMAND LIKE '%RESTORE%' OR COMMAND LIKE '%INDEX%' OR COMMAND LIKE '%DBCC%'

Mehernosh

Total article views: 2124 | Views in the last 30 days: 1
 
Related Articles
FORUM

BACKUP failed to complete the command

BACKUP failed to complete the command

FORUM

BACKUP DATABASE is terminating abnormally.

BACKUP failed to complete the command BACKUP DATABASE

BLOG

Backup/restore/checkdb/shrinkfile progress

Have you ever wonderet how long you need to wait for a backup or restore command to complete? If you...

FORUM

Error on completion of backup job

BACKUP failed to complete the command sp_executesql;1

SCRIPT

List database restore COMPLETION datetime

This script shows the COMPLETION datetime of database restore.

Tags
 
Contribute