码迷,mamicode.com
首页 > 其他好文 > 详细

使用 ShrinkFile EmptyFile 出错

时间:2016-07-13 22:40:50      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

在将tempdb数据库 ndf 文件清空时,遇到错误信息:

USE tempdb
GO
DBCC SHRINKFILE (Ntempdb_30 , EMPTYFILE)

DBCC SHRINKFILE: Page 26:24 could not be moved because it is a work table page.
Msg 2555, Level 16, State 1, Line 1
Cannot move all contents of file "tempdb_30" to other places to complete the emptyfile operation.

 

错误原因主要有两个:

1,其他User使用tempdb进行查询

If there are some persisted tables in TempDB and reside on the file you are trying to remove, it will not be able to Shrink or Remove. 

查看 tempdb 的Temporary Tables,能够看到当前系统正在使用的临时表

技术分享

通过sys.objects 也能查询到tempdb的temporary tables

  select *
  from tempdb.sys.objects
  where type=U

2,tempdb存在缓存

使用如下脚本清空缓存

USE [tempdb]
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREEPROCCACHE
GO
DBCC FREESESSIONCACHE
GO
DBCC FREESYSTEMCACHE ( ALL)
GO

DBCC SHRINKFILE (Ntempdb_30 , EMPTYFILE)
GO

 

参考文档:

DBCC SHRINKFILE: Page : could not be moved because it is a work table page Cannot move all contents of file "" to other places to complete the emptyfile operation.

使用 ShrinkFile EmptyFile 出错

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/5667811.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!