SharePoint Experts, Information Architects, Expert Witness

We provide consulting in a broad array of business and technology from architecture to design to deployment of global systems with a focus on surfacing data in the enterprise. Specialists in Microsoft, we are a premier provider of SharePoint Expertise (including 2016 and Office 365). We also provide Expert Witness/Legal Expert in eDiscovery, source discovery, patent infringement, piracy and more! We also have established SICG DLDS s.a. - our counterpart in Costa Rica that specializes in water systems (http://www.crwatersolutions.com) - Contact me direct: david_sterling@sterling-consulting.com or call 704-873-8846 x704.

Search This Blog

Saturday, February 17, 2018

Status of DBCC Shrink or Shrink through the GUI SQL Server

A note so I don't forget - if while doing a Database Shrink, you may want to know the status - the TSQL command is this:

SELECT percent_complete, start_time, status, command, estimated_completion_time, cpu_time, total_elapsed_time
FROM sys.dm_exec_requests
WHERE command = 'DbccFilesCompact'

Here's the detail on the table:

https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-requests-transact-sql

The key field you may be interested in is estimated_completion_time - to get the hours/minutes, use this:

Select dateadd(s, convert(bigint, <value>) / 1000, convert(datetime, ''))

For example:

Select dateadd(s, convert(bigint, 162114) / 1000, convert(datetime, ''))

will return '1900-01-01 00:02:42.000', i.e. 2 minutes, 42 seconds.

Be aware that the estimated_completion_time is just that, estimated but it will give you a rough idea on if you should grab another cup of coffee or go out to lunch.


No comments: