Skip to content

Instantly share code, notes, and snippets.

@mattmc3
Created April 6, 2017 14:29
Show Gist options
  • Select an option

  • Save mattmc3/69b2b4e6250617c79bf6c06f395ab471 to your computer and use it in GitHub Desktop.

Select an option

Save mattmc3/69b2b4e6250617c79bf6c06f395ab471 to your computer and use it in GitHub Desktop.
MSSQL - Truncate log file
-- http://dba.stackexchange.com/questions/6996/how-do-i-truncate-the-transaction-log-in-a-sql-server-2008-database
ALTER DATABASE {{db}} SET RECOVERY SIMPLE
go
SELECT name
FROM sys.master_files
WHERE database_id = DB_ID('{{db}}')
go
-- Shrink the log file
DBCC SHRINKFILE (N'{{db}}_log' , 0, TRUNCATEONLY)
go
ALTER DATABASE {{db}} SET RECOVERY FULL
go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment