Thursday, 29 May 2008

MSSQL: Truncate large Transaction Log files

Needed to truncate log files on prod server, found this nice tsql code snippet to handle this task.

/**SHRINK TRANSACTION LOGS**/
/**RUN EACH STEP SEPARATELY **/

--STEP 1 - Select database & get its logical name
USE [drd-data];
SELECT * FROM sysfiles;

--STEP 2 - From result window input file name to shrinkfile command
BACKUP LOG [drd-data] WITH TRUNCATE_ONLY
DBCC
SHRINKFILE('drd-data_log', 95);

No comments: