DBCC shrink file throwing server error

  • Hi,

    I am getting server error while trying to shrink the datafile

    history: we did some huge data purge on the db.

    original size of file : 1778050 MB

    free space: 45%

    ScriptUsed:

    USE [office]

    GO

    DBCC SHRINKFILE (N'office_db' , 1757810)

    GO

    Msg 0, Level 11, State 0, Line 0

    A severe error occurred on the current command. The results, if any, should be discarded.

    can someone help me on this issue?

  • Is this SQL Server 2005? If so, what is the version number/patch level?

    Joie Andrew
    "Since 1982"

  • Jo_DBA (6/16/2015)


    Hi,

    I am getting server error while trying to shrink the datafile

    history: we did some huge data purge on the db.

    original size of file : 1778050 MB

    free space: 45%

    ScriptUsed:

    USE [office]

    GO

    DBCC SHRINKFILE (N'office_db' , 1757810)

    GO

    Msg 0, Level 11, State 0, Line 0

    A severe error occurred on the current command. The results, if any, should be discarded.

    can someone help me on this issue?

    It's an odd thing. There's no reason for it but I don't believe that you can be in the database that you're attempting to shrink a file of. Try USE MASTER instead.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • It's an odd thing. There's no reason for it but I don't believe that you can be in the database that you're attempting to shrink a file of. Try USE MASTER instead.

    Actually you have to be in the database you want to use DBCC SHRINKFILE against. There is no way to specify the db when using DBCC SHRINKFILE, only file id or file name. If you are in MASTER DBCC SHRINKFILE will always try to shrink data/log files in MASTER.

    Joie Andrew
    "Since 1982"

  • Yeah... you're right, Joie. I'm not sure which command I was thinking about but it certainly isn't DBCC ShrinkFile that has this problem. Thank you for the catch.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply