DBCC shrinkdatabase(MyDB,10)

  • Hi,

    Can i make use of the following command in the live production server, as the database size of MyDB is 16 GB, if i execute the following command it will take a huge amount of time. Is it fine and what exactly the below command will do, will it reduce the db size or what it will do please let me know.

    DBCC shrinkdatabase(MyDB,10)

    With Regards

    Daksh

  • The DBCC Shrinkdatabase command would shrink the size of your database to the specified size. But why do you want to use this command on a live prod database? Usually this is done to free up space on the drive that too on the log file because the live processes will be using data from this DB. It might also impact on the performance. Check if you log file size is too much, lets say over 4 or 5 Gb then you can either do a Transaction log backup on this DB which would free up some space or if you want to reduce the size to the minimum level use this command

    Use MyDB

    GO

    BACKUP LOG MyDB WITH TRUNCATE_ONLY

    DBCC SHRINKFILE(MyDB_Log)

    But make sure you let you manager know why you are doing this since it is production server...:)

    The_SQL_DBA
    MCTS

    "Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives."

  • It will not take longer time. Also include the log file name in the command mentioned below, suppose you log file name is MyDB_log1.ldf then the command would become

    Use MyDB

    GO

    BACKUP LOG MyDB WITH TRUNCATE_ONLY

    DBCC SHRINKFILE(MyDB_log1)

    You can view your log file name and the size from properties by right clicking on the MyDB database and the Transaction Log tab.

    Thanks!!! 🙂

    The_SQL_DBA
    MCTS

    "Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives."

Viewing 3 posts - 1 through 2 (of 2 total)

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