Wednesday, April 10, 2013

SQL Server 2008 SHRINK LOG FILE



It’s not a good practice to shrink the log files. But sometimes it needs for us.

USE [master] 
GO 
ALTER DATABASE [Database Name] SET RECOVERY SIMPLE WITH NO_WAIT 
GO 
USE [Database Name] 
GO 
DBCC SHRINKFILE (‘Database Name.ldf') 
GO 
ALTER DATABASE [Database Name] SET RECOVERY FULL WITH NO_WAIT
GO
USE [Database Name] 
GO


USE [Database Name];
GO
SELECT file_id, name FROM sys.database_files;
GO
DBCC SHRINKFILE (2, TRUNCATEONLY);

No comments:

Post a Comment