Archive for October, 2010
Truncate MSSQL 2008 Database Log File
by Steve O Hernandez on Oct.27, 2010, under Technology
Use this simple script to truncate the log file of your database. Where yourDB is the database name. By default in MSSQL 2008 the log file name is the same as the database file name, with _log appended at the end. If your database deviates from this (possible if the server was upgraded from 2005 or the file name intentionally changed), use the next snippet of code to find the name of the log file.
TRUNCATE DATABASE LOG FILE
USE [master]
GO
ALTER DATABASE [yourDB] SET RECOVERY SIMPLE WITH NO_WAIT
USE [yourDB]
DBCC SHRINKFILE(yourDB_log, 1)
ALTER DATABASE [yourDB] SET RECOVERY FULL WITH NO_WAIT
GO
FIND LOG FILE NAME
sp_helpdb yourDB