DBCC ShrinkFile

  • DBCC ShrinkDatabase accepts a parameter for the amount of free-space, as a percentage, to be left in the database file(s) after the shrink takes place.

    DBCC ShrinkFile, on the other hand, accepts a parameter to specify the size of the data file.

    How do you determine how much space is currently being used (or how much space is free) in the target datafile?

     

  • Hi..

    U can use this to check the currently available space in the current DB

    SP_SPACEUSED

     


    Regards,

    Papillon

  • Papillon,

    Thanks for the reply.  SP_SPACEUSED gets me the size of the database and the amount of unused space.  What I need is the amount of unused space in each datafile.  I have 3 filegroups with 3 datafiles each.  If I used DBCC shrinkdatabase (dbname, 10), my understanding is that it leaves 10% free space in each datafile.

    DBCC shrinkfile, which I'd prefer to use, doesn't have a "percent free" parameter, simply a target size (and a couple other parameters not related to size).

    I'm hoping to find the used space in each datafile so that when I use DBCC shrinkfile, I can specify 10% over the used space.

    Mitch

     

  • In SQL Enterprise Manager, switch to Task Pad view for the database.

  • GS,

    That did it.  Thanks very much.

    Mitch

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

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