Shrink sql database transaction log file

--Database Name
USE Database_Name;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE Database_Name
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (Database_Name_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE Database_Name
SET RECOVERY FULL;
GO

When your sql database transaction log file is too big than shrink it . It will take about 30 second. You can run this script any time you want.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s