How to shrink the transaction log file in SQL Server

 

How to shrink the transaction log file in SQL Server:

USE YOURDBNAME

GO  

-- Truncate the log by changing the database recovery model to SIMPLE.  

ALTER DATABASE YOURDBNAME

SET RECOVERY SIMPLE;  

GO  

-- Shrink the truncated log file to 1 MB.  

DBCC SHRINKFILE (YOURDBNAME_log, 1);  -- log file name

GO  

-- Reset the database recovery model.  

ALTER DATABASE YOURDBNAME

SET RECOVERY FULL;  

GO




Post a Comment

0 Comments