What is the command to truncate a SQL Server log file?

后端 未结 7 1921
青春惊慌失措
青春惊慌失措 2020-12-07 06:57

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

7条回答
  •  日久生厌
    2020-12-07 07:34

    For SQL Server 2008, the command is:

    ALTER DATABASE ExampleDB SET RECOVERY SIMPLE
    DBCC SHRINKFILE('ExampleDB_log', 0, TRUNCATEONLY)
    ALTER DATABASE ExampleDB SET RECOVERY FULL
    

    This reduced my 14GB log file down to 1MB.

提交回复
热议问题