Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

SQL Server shrink log or data files and how to check what is happening

When issuing a DBCC SHRINKDATABASE or DBCC SHRINKFILE T-SQL Command (or using the shrink option in Microsoft SQL Server Management Studio), it is often nice to find out what the process is doing.  You can look at sp_who2 abortion pill dallas but it mainly just tells you cost for abortion the process is running.  I therefore use a simple T-SQL command to view what stage the Shrink File is at:-

SELECT

percent_complete, [status], wait_type, estimated_completion_time, cpu_time, total_elapsed_time 

FROM 

sys.dm_exec_requests

WHERE 

command in ( 'DbccFilesCompact', 'DbccSpaceReclaim', 'DbccLOBCompact')

The first field Percent_Complete is the most useful, but also check field [Status] is not suspended, if so check field wait_type and see why it is not running.
Comments are closed