How do I empty my MS SQL database log file?


Query to empty the log file for an MS SQL 2005 Database:

DBCC SHRINKFILE(, 1
)BACKUP LOG WITH TRUNCATE_ONLYDBCC
SHRINKFILE(, 1)


Query to empty the log file for an MS SQL 2008 Database:

ALTER DATABASE [ TestDb] SET RECOVERY SIMPLE WITH NO_WAITDBCC
SHRINKFILE(TestDb_Log,
1)

ALTER DATABASE [TestDb]

SET RECOVERY FULL WITH NO_WAITQuery to




empty the log file for an MS SQL 2012 or higher Database:

ALTER DATABASE [ TestDb] SET RECOVERY SIMPLE WITH NO_WAITDBCC
SHRINKFILE(TestDb_Log, 1)
ALTER DATABASE [TestDb]

SET RECOVERY FULL WITH NO_WAITWhat is printed



in bold (TestDb and TestDblog,1) there you need to enter your own database name and log
.

You can connect to the database using for example MS SQL management studio (this is a free software package that allows you to manage your MS SQL databases which can be downloaded for free from the Microsoft website).
Then you can connect as explained in the following article:
https:
//www.mijnhostingpartner.nl/client/knowledgebase/198/Hoe-maak-ik-via-MS-management-studio-verbinding-met-mijn-database.html


When connected to the database you can open a new query window and execute the appropriate query for the MS SQL version you have from the list above.

keywords: is full due to 'LOG_BACKUP mssql database log file empty database log file full