Have you ever been performing a DBCC SHRINKFILE and wondered how long it was going to take? The Backup/Restore screen shows percent complete, how about DBCC CHECKDB?
Here's a neat query that can help with that:
Select * from sys.dm_exec_requests
This query returns information about every request that the SQL Server is executing.
One of the columns returned is Percent_Complete. However, this column is only populated for the following commands:
ALTER INDEX REORGANIZE
AUTO_SHRINK option with ALTER DATABASE
BACKUP DATABASE
DBCC CHECKDB
DBCC CHECKFILEGROUP
DBCC CHECKTABLE
DBCC INDEXDEFRAG
DBCC SHRINKDATABASE
DBCC SHRINKFILE
RECOVERY
RESTORE DATABASE
ROLLBACK
TDE ENCRYPTION
I have four large databases that I have to shrink when they are copied to the development. These can take quite a while, so I use this query to monitor status.
Check out the
documentation for more details!
peace