Skip to content

Instantly share code, notes, and snippets.

@mattmc3
Last active January 23, 2019 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmc3/0eddc1d02f7b799ef966b5f16cfe1c26 to your computer and use it in GitHub Desktop.
Save mattmc3/0eddc1d02f7b799ef966b5f16cfe1c26 to your computer and use it in GitHub Desktop.
MSSQL - Backup to nul
use [MY_DATABASE]
go
checkpoint
go 50
-- see what's blocking the log
select name, log_reuse_wait_desc, db.*
from sys.databases db
where db.name = 'MY_DATABASE'
use master
go
-- don't do full backup
-- backup database [MY_DATABASE] to disk = 'NUL' with compression, stats = 1;
backup log [MY_DATABASE] TO DISK = 'nul' WITH STATS = 1;
use [MY_DATABASE]
go
DBCC SHRINKFILE ([MY_DATABASE_LOG], 1, truncateonly)
go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment