I need to empty an LDF file before sending to a colleague. How do I force SQL Server to truncate the log?
I need to empty an LDF file before sending to a colleague. How do I force SQL Server to truncate the log?
In management studio:
Properties, then Options.Tasks -> Shrink -> FilesAlternatively, the SQL to do it:
ALTER DATABASE mydatabase SET RECOVERY SIMPLE
DBCC SHRINKFILE (mydatabase_Log, 1)
if I remember well... in query analyzer or equivalent:
BACKUP LOG databasename WITH TRUNCATE_ONLY
DBCC SHRINKFILE ( databasename_Log, 1)
Since the answer for me was buried in the comments. For SQL Server 2012 and beyond, you can use the following:
BACKUP LOG Database TO DISK='NUL:'
DBCC SHRINKFILE (Database_Log, 1)