Saturday, May 28, 2011

Clean up the log file in a SQL server database

The syntax for clean up the log file as it cause more burden on the server is as follows..

USE
GO
DBCC SHRINKFILE(, )
BACKUP LOG WITH TRUNCATE_ONLY
DBCC SHRINKFILE(, )

Apply the above syntax to a normal database.The below is the example for it...

USE dbproduct
GO
DBCC SHRINKFILE(dbproduct_log, 10)
BACKUP LOG dbproduct WITH TRUNCATE_ONLY
DBCC SHRINKFILE(dbproduct_log, 10)