How do I Empty the Log File for a Database?

×
In normal usage a Microsoft SQL transaction log will grow gradually over time and the amount of free space in the database will be normal. However, sometimes the transaction log can get larger than needed if you have done a lot of maintenance or missed a backup and transaction log will have too much free space in it. The DBCC SHRINKFILE command will help in this scenario:

The SHRINKFILE command will not remove any log data that hasn't been backed up. Either do a normal backup or run the following command:

BACKUP LOG {Database Name} TO DISK='NUL'

Then run:

DBCC SHRINKFILE({Logical Filename})

{Logical Filename} is the Logical File Name of your database file which can be found in Database Properties under the File tab. Use the Logical Filename with a File Type of LOG.

Remember to take a full backup afterwards because this breaks the chain of transaction log backups.