SteveOH

Archive for October, 2010

Truncate MSSQL 2008 Database Log File

by on Oct.27, 2010, under Technology

Use this simple to truncate the log file of your database.   Where yourDB is the database name.  By default in 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 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

Leave a Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!