I need to empty an LDF file before sending to a colleague. How do I force SQL Server to truncate the log?
+4
A:
In management studio:
- Right-click the database, choose properties, then options.
- Make sure "Recovery model" is set to "Simple", not "Full"
- Click Ok
- Right-click the database again, choose tasks -> shrink files
- Change file type to "log"
- Click ok.
Alternatively, the SQL to do it:
ALTER DATABASE mydatabase SET RECOVERY SIMPLE
DBCC SHRINKFILE (mydatabase_Log, 1)
Blorgbeard
2008-09-02 19:51:12
+2
A:
backup log logname with truncate_only followed by a dbcc shrinkfile command
SQLMenace
2008-09-02 19:51:59
+9
A:
if I remember well... in query analyzer or equivalent:
BACKUP LOG databasename WITH TRUNCATE_ONLY
DBCC SHRINKFILE ( databasename_Log, 1)
ila
2008-09-02 19:53:31
This is definitely better than setting the database recovery model to SIMPLE (as in Blorgbeard's answer) because if your recovery model is FULL, you have it set that way for a reason.
Scott Whitlock
2010-10-19 17:13:45