search cancel

Shrinking the database filegroups manually

book

Article ID: 230613

calendar_today

Updated On:

Products

Data Center Security Server Advanced Critical System Protection

Issue/Introduction

Commands to shrink database manually.

Resolution

Following can be performed to shrink the partition.

  • Run the below command for the partition files which are consuming GB's of space.
          EXEC sp_helpfile
  • Run the below command to check the time stamp of the partition

         select top 1 * from CSPEVENT with (NOLOCK) where event_dt_day_of_Yr = <Partition number>

  • Run the query to find the number of events in particular partition
    select count from CSPEVENT with (NOLOCK) where event_dt_day_of_Yr = <Partition number>
  • Once confirmed that events are zero, then ran the below command to shrink the partition.
          dbcc shrinkfile (<PartitionName>, target_size)
          Note : Target_size is in MB
  • The Partition got shrinked successfully and the disk space was reclaimed.