Forum Discussion

pmrzyglod's avatar
pmrzyglod
Copper Contributor
Apr 22, 2024

MSSQL - Shrinking database to minimum available size doesn't work

Hello Community,

Im having a really hard time getting the mssql database file shrinked to minimum available size that SSMS shows in GUI. I really need help and explanation because it's not relevant on any tech forum I found about it.
My issue is that I want to shrink db data file and in GUI, the minimum size of the file is 2314MB.

I apply the shrink - it does nothing. The db file still remains the same and I can repeat the process forever and nothing will happen to file.
Im looking for a good explanation of this behaviour as tried lot of different methods found on the internet and I can't make this shrink to happen.

Best regards, Paweł

  • Arshad440's avatar
    Arshad440
    Brass Contributor
    Hi,
    Try to shrink the database as Simple Recovery Model.you could check the Recovery model of Database by

    Database->Options->Recovery Model
    make it to Simple and try to shrink The DataBase

    Regards
    Arshad
    • pmrzyglod's avatar
      pmrzyglod
      Copper Contributor

      Arshad440 Hi, thanks for the reply.

      I forgot to mention that my db stays in simple mode recovery from the beginning.

      Best regards

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    pmrzyglod , first, why do you want to shrink the database at all? It is very small and shrink will cause index fragmentation and so performance issues.

     

    What does the statement below return?

    exec sp_spaceused;

     

    • pmrzyglod's avatar
      pmrzyglod
      Copper Contributor

      olafhelper Hi, thanks for the reply.
      This are the results of sp_spaceused;

      Answering your question about the shrink. Issue here is that this DB works in express for demo purposes and at the beginning it wasn't a problem as the db was staying at around 4GB. After some time it kept to grow even tho data that was comming through wasn't bigger. So for now It keeps going up to 10GB and Im forced to keep less and less data. My opinion is that it is keeping reserved space for tables that once could grow bigger than usual and it broke the whole inflow.

      Best regards

      • olafhelper's avatar
        olafhelper
        Bronze Contributor
        There is a mismatch between the information; the database has only 771 MB "unallocated space" = free space, you can't shrink below.

Resources