Skip to content

Instantly share code, notes, and snippets.

@geo-stanciu
Last active May 11, 2019 17:00
Show Gist options
  • Save geo-stanciu/da9afa935f3f1d9fb1f67c1a53433564 to your computer and use it in GitHub Desktop.
Save geo-stanciu/da9afa935f3f1d9fb1f67c1a53433564 to your computer and use it in GitHub Desktop.
SQL Server - Shrink the transaction log file
-- First, create a full backup
sqlcmd -d devel
use devel
go
select name,recovery_model_desc from sys.databases
go
ALTER DATABASE devel SET RECOVERY simple
go
DBCC SHRINKFILE (devel_log , 1)
go
ALTER DATABASE devel SET RECOVERY full
go
exit
-- Now create another backup.
-- AFAIK shrinking made impossible to create a point in time recovery prior to the backup taken earlier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment