Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to run the following command in Sql Server 2008 R2:

DBCC SHRINKFILE('filename')

When I try to run this command, I get the following error:

Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.

Can anyone tell me why I am getting this error and how to resolve this issue?

Thanks!

share|improve this question

migrated from stackoverflow.com Jan 21 '12 at 23:27

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 2 down vote accepted

Have you tried specifying both the file name and the target size in MB, e.g.

DBCC SHRINKFILE('filename', 20);

Or the TRUNCATEONLY option, which doesn't try any of the nasty stuff like reorganizing all of your physical data:

DBCC SHRINKFILE('filename', TRUNCATEONLY);

Also you could try making sure the database is in single user mode first:

ALTER DATABASE db SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

...and turn off any backup / log backup or other maintenance jobs that may be conflicting with your shrink operation. If it still occurs, please run a CHECKDB against this database and let us know the results:

DBCC CHECKDB (db) WITH NO_INFOMSGS, ALL_ERRORMSGS;

But just as a side note, you do know that shrinking is bad and should usually be reserved for extraordinary events and circumstances, right?

share|improve this answer
    
+1 for pointing out that shrinking a DB actually causes worse performance, for some reason people seem to think that a smaller database always means it will be faster to load off the disk, they ignore that it will be slower for writes and very often will be fragmented as well. –  Seph Jul 13 '11 at 14:38
    
setting it to single user allowed the shrink to process...thanks! p.s. this had to happen due to an extraordinary event, not by choice..lol –  thiag0 Jul 13 '11 at 16:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.