<p>I need to empty an LDF file before sending to a colleague.  How do I force SQL Server to truncate the log?</p>

[{'answer_id': 40420, 'author': 'Blorgbeard', 'author_id': 369, 'author_profile': 'https://Stackoverflow.com/users/369', 'pm_score': 8, 'selected': False, 'text': '<p>In management studio:</p>\n\n<ul>\n<li>Don\'t do this on a live environment, but to ensure you shrink your dev db as much as you can:\n\n<ul>\n<li>Right-click the database, choose <code>Properties</code>, then <code>Options</code>.</li>\n<li>Make sure "Recovery model" is set to "Simple", not "Full"</li>\n<li>Click OK</li>\n</ul></li>\n<li>Right-click the database again, choose <code>Tasks</code> -> <code>Shrink</code> -> <code>Files</code></li>\n<li>Change file type to "Log"</li>\n<li>Click OK.</li>\n</ul>\n\n<p>Alternatively, the SQL to do it:</p>\n\n<pre><code> ALTER DATABASE mydatabase SET RECOVERY SIMPLE\n DBCC SHRINKFILE (mydatabase_Log, 1)\n</code></pre>\n\n<p>Ref: <a href="http://msdn.microsoft.com/en-us/library/ms189493.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms189493.aspx</a></p>\n'}, {'answer_id': 40421, 'author': 'SQLMenace', 'author_id': 740, 'author_profile': 'https://Stackoverflow.com/users/740', 'pm_score': 2, 'selected': False, 'text': '<p>backup log logname with truncate_only followed by a dbcc shrinkfile command</p>\n'}, {'answer_id': 40427, 'author': 'ila', 'author_id': 1178, 'author_profile': 'https://Stackoverflow.com/users/1178', 'pm_score': 8, 'selected': True, 'text': '<p>if I remember well... in query analyzer or equivalent:</p>\n\n<pre><code>BACKUP LOG  databasename  WITH TRUNCATE_ONLY\n\nDBCC SHRINKFILE (  databasename_Log, 1)\n</code></pre>\n'}, {'answer_id': 6978809, 'author': 'Nathan R', 'author_id': 584878, 'author_profile': 'https://Stackoverflow.com/users/584878', 'pm_score': 6, 'selected': False, 'text': "<p>For SQL Server 2008, the command is:</p>\n\n<pre><code>ALTER DATABASE ExampleDB SET RECOVERY SIMPLE\nDBCC SHRINKFILE('ExampleDB_log', 0, TRUNCATEONLY)\nALTER DATABASE ExampleDB SET RECOVERY FULL\n</code></pre>\n\n<p>This reduced my 14GB log file down to 1MB.</p>\n"}, {'answer_id': 7361576, 'author': 'Matej', 'author_id': 117965, 'author_profile': 'https://Stackoverflow.com/users/117965', 'pm_score': 5, 'selected': False, 'text': "<p>For SQL 2008 you can backup log to <code>nul</code> device:</p>\n\n<pre><code>BACKUP LOG [databaseName]\nTO DISK = 'nul:' WITH STATS = 10\n</code></pre>\n\n<p>And then use <code>DBCC SHRINKFILE</code> to truncate the log file.</p>\n"}, {'answer_id': 21087363, 'author': 'Rask', 'author_id': 325049, 'author_profile': 'https://Stackoverflow.com/users/325049', 'pm_score': -1, 'selected': False, 'text': '<p>Another option altogether is to detach the database via Management Studio. Then simply delete the log file, or rename it and delete later. </p>\n\n<p>Back in Management Studio attach the database again. In the attach window remove the log file from list of files.</p>\n\n<p>The DB attaches and creates a new empty log file. After you check everything is all right, you can delete the renamed log file.</p>\n\n<p>You probably ought not use this for production databases.</p>\n'}, {'answer_id': 61259458, 'author': 'rip747', 'author_id': 31278, 'author_profile': 'https://Stackoverflow.com/users/31278', 'pm_score': 0, 'selected': False, 'text': "<p>Since the answer for me was buried in the comments. For SQL Server 2012 and beyond, you can use the following:</p>\n\n<pre><code>BACKUP LOG Database TO DISK='NUL:'\nDBCC SHRINKFILE (Database_Log, 1)\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/40402', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1042/']