收缩SQL Server数据库文件
收缩整个数据库
DBCC SHRINKDATABASE (dbName)
收缩单个文件
DBCC SHRINKFILE (FileName)
查找所有的文件名称
USE dbName
EXEC sp_helpfile
例如对 AdventureWorks 数据库
/* Shrink Whole AdventureWorks Database */
DBCC SHRINKDATABASE (AdventureWorks)
GO
/* Get the Logical File Name */
USE AdventureWorks
EXEC sp_helpfile
GO
/* Shrink MDF File of AdventureWorks Database */
DBCC SHRINKFILE (AdventureWorks_Data)
GO
查看执行完成率
SELECT percent_complete, start_time, status, command, estimated_completion_time, cpu_time, total_elapsed_time
FROM sys.dm_exec_requests