Purge the log file of a SQL 2012 database

I have a database with 100MB of data and 76GB of log transactions.  How do I reduce the log file to a reasonable size?
compuzak1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
Run a backup on the database. Make sure you have a regular transaction log backups..
Backup the transaction log.
Use shrink to reduce,

Use dbcc opentran(databasename)

To see if there is an active transaction that is preventing the shrinking of the file.

You can use dbcc shrinkfile, with trunk.
Change the database mode to simple and shrink the file. Then reset.
0
compuzak1Author Commented:
Is there a clean way to reduce the size of the log through the Sql Server Management Studio?  I don't need the logs or the log data, so I don't need to back it up unless the backup also does a purge.

Ideally, I would like to keep about a month of transactions and have it automatically purge.
0
arnoldCommented:
The backup closes all completed transactions freeing up space within the log binary file.
Using ssms right clck on the DB, tasks, shrink files, switch to the log and it will tell you how much is in use and that is the minimum account to which the transaction log can be shrunk.

After shrinking, make sure you limit the size of the transaction log. If you do not need to recover the transactions for the recovery/restore, change he recovery model to simple from full.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony PerkinsCommented:
I don't need the logs or the log data, so I don't need to back it up unless the backup also does a purge.
Perhaps you are not aware, but the transaction log in an integral part of the database, so saying you "don't need the logs or the log data" is like saying you don't care about your data.

If you are unwilling or unable to make frequent transaction log backups, then change the database Recovery Model to Simple (you will lose the possibility of point-in-restores):
ALTER DATABASE YourDatabaseName SET RECOVERY SIMPLE

Once you have done that, then do the following (this should only be done on an emergency basis, never schedule it):
USE YourDatabaseName
GO
CHECKPOINT
Go
DBCC SHRINKFILE(2, 4000)                 -- 4000MB change appropraitely
0
compuzak1Author Commented:
Thanks for the assistance, we setup an automated backup and data mainteance plan and now the log file is very small and will maintain that size as we are backing up each night.  Previously we were backing up the entire server and not using the SQL database backup and maintenance features, which are obviously a much better solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.