dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Get-DbaEstimatedCompletionTime

Gets execution and estimated completion time information for queries. Percent complete will show 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

Sometimes the query is good at its job, but sometimes not so much. It’s fun to use anyway.

Screenshots

Examples

To get estimated completion times for queries performed against the entire server

Get-DbaEstimatedCompletionTime -SqlInstance sql2016

To get estimated completion times for queries performed against the entire server PLUS the SQL query text of each command

Get-DbaEstimatedCompletionTime -SqlInstance sql2016 | Select *

To get results for commands whose queries only match specific text (match is like LIKE but way more powerful)

Get-DbaEstimatedCompletionTime -SqlInstance sql2016 | Where-Object { $_.Text -match ‘somequerytext’ }

To get estimated completion times for queries performed against the Northwind, pubs, and Adventureworks2014 databases

Get-DbaEstimatedCompletionTime -SqlInstance sql2016 -Databases Northwind,pubs,Adventureworks2014

References

Patience and sys.dm_exec_requests
sys.dm_exec_requests (Transact-SQL)

Get-Help

From PowerShell, execute Get-Help Get-DbaEstimatedCompletionTime -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-DbaEstimatedCompletionTime.ps1 on GitHub
 

Related commands