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

后端 未结 7 1924
青春惊慌失措
青春惊慌失措 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 07:31

    For SQL 2008 you can backup log to nul device:

    BACKUP LOG [databaseName]
    TO DISK = 'nul:' WITH STATS = 10
    

    And then use DBCC SHRINKFILE to truncate the log file.

提交回复
热议问题