shrink – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Tue, 13 Aug 2019 09:33:06 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Shrink SQL Server Transaction Log Files using DBCC SHRINKFILE https://tecadmin.net/shrink-sql-server-transaction-log-files-dbcc-shrinkfile/ https://tecadmin.net/shrink-sql-server-transaction-log-files-dbcc-shrinkfile/#comments Sat, 02 Mar 2013 12:58:08 +0000 https://tecadmin.net/?p=369 Sometimes SQL Server logs files acquire a large space on the disk. In that case, we need to reduce the size of the log file to claim some space. But truncating or reducing database log file in SQL Server 2008 can be quite difficult. It also has its own issues. This article contains a set [...]

The post How to Shrink SQL Server Transaction Log Files using DBCC SHRINKFILE appeared first on TecAdmin.

]]>
Sometimes SQL Server logs files acquire a large space on the disk. In that case, we need to reduce the size of the log file to claim some space. But truncating or reducing database log file in SQL Server 2008 can be quite difficult. It also has its own issues.

This article contains a set of commands to Shrink Log Files of SQL Server database.

Generally this command is I prefer to take a backup of the database before executing below command for a safer side

Shrink SQL Server Transaction Log Files

First of all, check the actual name of log files stored in SQL server records using the following SQL query. Execute these queries in using SQL Server management studio query browser.

USE DATABASE_NAME;
GO

SELECT FILE_NAME(2);
GO

Now, use the DBCC SHRINKFILE SQL command to shrink log files. The database must be running in SIMPLE recovery mode. Open the query windows in SQL Server management studio and run the following command. You

Make sure to change DATABASE_NAME with actual database name and LOG_FILE_NAME with log file name found in the above step. The below example query will shrink the log file to 1000MB.

USE DATABASE_NAME;
GO

ALTER DATABASE DATABASE_NAME
SET RECOVERY SIMPLE;
GO  

DBCC SHRINKFILE (LOG_FILE_NAME, 1000);
GO  

ALTER DATABASE DATABASE_NAME
SET RECOVERY FULL;
GO  

All done. Now check the size of the log files, I hope you will get the expected results.

The post How to Shrink SQL Server Transaction Log Files using DBCC SHRINKFILE appeared first on TecAdmin.

]]>
https://tecadmin.net/shrink-sql-server-transaction-log-files-dbcc-shrinkfile/feed/ 1