SQL Server Truncate Transaction Log script

Many time, it happens in live sql server which has big transaction log file, you run DBCC SHRINKFILE command and see no effect of it on the transaction log file. You can use following magical five line at that time and you will done. It shrinks the trucated log File to minimum size possible.
————————————————————————-
USE DBName
GO
DBCC SHRINKFILE(transactionlogfilename, 1)
BACKUP LOG WITH TRUNCATE_ONLY
DBCC SHRINKFILE(transactionlogfilename, 1)
————————————————————————
Happy Working!!!!

Advertisements
Posted in T-sql. 12 Comments »

12 Responses to “SQL Server Truncate Transaction Log script”

  1. Anonymous Says:

    Thank you. I had an 18GB transaction log that grew by ~1GB per day (netflow statistics from a router). Your script allowed me to go from 18GB to 3.4MB.

  2. Anonymous Says:

    Thank you. I had an 18GB transaction log that grew by ~1GB per day (netflow statistics from a router). Your script allowed me to go from 18GB to 3.4MB.

  3. rizz Says:

    Thanks it helped me too to reduce 40 GB log to 25 mb…. Thanks a lot.

  4. rizz Says:

    Thanks it helped me too to reduce 40 GB log to 25 mb…. Thanks a lot.

  5. rizz Says:

    Hey thanks… worked from 40GB to 25 MB… in seconds.

  6. rizz Says:

    Hey thanks… worked from 40GB to 25 MB… in seconds.

  7. rizz Says:

    Hey thanks… worked from 40GB to 25 MB… in seconds.

  8. rizz Says:

    Hey thanks… worked from 40GB to 25 MB… in seconds.

  9. rizz Says:

    Hey thanks… worked from 40GB to 25 MB… in seconds.

  10. rizz Says:

    Hey thanks… worked from 40GB to 25 MB… in seconds.


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

%d bloggers like this: