收缩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

 

posted @ 2016-07-27 10:40  BITALKER  阅读(193)  评论(0编辑  收藏  举报