Tuesday, March 22, 2011

DBCC Shrinkfile unable to Shrinkfile

Many times it happens that you will not able to shrink datafile using DBCC Shrinkfile command. There may be various reason/error for it. One of them says as mentioned below:

"file id of database id cannot be shrunk as it is either being shrunk by another process or is empty"

This happens when already a DBCC shrinkfile has been run and due to some reason it was unable to shrink the file and the internal files are not re-organized or file has not grown to shrink. Or SQL server somewhere it feels that the file you are shrinking is in middle of Shrinking process

One of the solution for this file is to add some MB of data to the file which you are trying to shrink and then use DBCC Shrinkfile. This will work as adding a few MB to the data file resets an internal counter or switch that tells it it's not in the middle of a shrink now

No comments:

Post a Comment