How to shrink Transaction log in SQL Server 2008 R2

SbhatSbhat Member Posts: 301
Hi Folks -

I am using SQL Server 2008 R2 and trying to shrink the Transaction log and it has completely changed from SQL Server 2005. Does anyone know the SQL script to shrink the transaction log for SQL Server 2008 R2.

Any help is highly appreciated.

SB.

Comments

  • lvanvugtlvanvugt Member Posts: 774
    I know things have changed, but as I am doing this not frequently I always have to 'reinvent the wheel'.

    Trying that now I was trying to reconstruct the Query I always used for this, but I read the help topic "How to: Shrink a File (SQL Server Management Studio)" and saw you can use a task from the UI of SSMS:

    1. In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.

    2. Expand Databases and then right-click the database that you want to shrink.

    3. Point to Tasks, point to Shrink, and then click Files.

    4. Select the file type and file name.

    I applied it to the log file and ... it was shrinked.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • krikikriki Member, Moderator Posts: 9,110
    Before shrinking the transactionlog, consider that this is something that should happen in very rare circumstances.
    Shrinking the logfile can create fragmentation on the disk.

    So: before you shrink your logfile: how big is it and how much data contains your DB?
    If you logfile is bigger than that, it might be a good idea to shrink it a little. Generally I try to create a logfile that is +- the size of the data in the database to be sure that a complete rebuild index can be done without growing the logfile.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.