Posted tagged ‘ldf’

SQL: Truncating a SQL Database Log

June 9, 2009

Thanks to John McBride for helping me with this.

1. In SQL Management Studio, make sure you are connected to ‘master’ in the available databases drop-down box.

2. Click ‘New Query’ to open a query window.

3. Get the logfile name by:

     a. Right-click the database

     b. Select Properties

     c. Click Files

     d. Note the name of the log file.

4. Type the following in the query window:

          Use <YOUR_DB_NAME>
          Go
          backup log <YOUR_DB_NAME> with truncate_only
          go
          dbcc shrinkfile(<YOUR_DB_LOGFILE_NAME,1)
          go

5. Click the Execute button.

Advertisements