sql server log file size and free up space

This should help reduce the log file size and free up space. If there are pending transactions or the log is in FULL mode, the log should be backed up before performing shrink.

DBCC SQLPERF(LOGSPACE);  --  Checks the space used by the log
DBCC OPENTRAN ('mydb');  -- Checks for open transactions in the database
BACKUP LOG mydb TO DISK = 'C:\_Backup\mydb_log.bak';  --  Backs up the log (required in FULL mode)
DBCC SHRINKFILE (N'mydb_log', TRUNCATEONLY);  -- Shrinks the log file, freeing up unused space

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *