7developers blog

Useful articles, videos and code examples from professional developers

Shrink Log file in MS SQL server 2008

USE YOUR_DB;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE YOUR_DB
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (2, 1);  -- here 2 is the file ID for trasaction log file,you can also mention the log file name (YOUR_DB_log)
GO
-- Reset the database recovery model.
ALTER DATABASE YOUR_DB
SET RECOVERY FULL;
GO


Loading