Solved

SQL Server 2005 - Truncate/Shrink Log File

Posted on 2010-09-22
6
605 Views
Last Modified: 2012-05-10
Hi,

I have a .LDF log file which currently stands at 88GB and still growing.

I found a previous thread on this topic which I think details what I need to do in order to shrink this file:

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_20092260.html?sfQueryTermInfo=1+10+30+ldf+sql+truncat

However, I am literally a beginner on this subject with no SQL experience what so ever.

I tried running this command from "SQLCMD" but it doesn't work, I'm obviously doing something wrong.

I was hoping someone could offer a step by step guide on what I need to do?

For instance, where do i run the command "DBCC SHRINKFILE (<filename>,<target size>, TRUNCATEONLY)"??

SQL Server version is 2005.

Many thanks.
0
Comment
Question by:paul-ashton
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>I tried running this command from "SQLCMD" but it doesn't work

error is?
0
 
LVL 11

Assisted Solution

by:JoeNuvo
JoeNuvo earned 100 total points
Comment Utility
Check your database recovery model first by ... right click on Database Name -> Options section -> Recovery Model

If it is "Full" , you need to perform either database backup, or transacion log backup first
in order to able to shrink logfile.
0
 

Author Comment

by:paul-ashton
Comment Utility
Thanks for the quick replies.

AngelIII - The error was "DBCC - Unknown option"

JoeNuvo - The database recovery model is set to "Full".  When you say back up the database, do you mean in terms of having a copy in the event it goes wrong, or is it an "Sql prerequisite" that I run some sort of backup procedure before I can shrink the database?

Thanks again.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 100 total points
Comment Utility
can you show a screenshot of how you try to run this?
0
 
LVL 2

Accepted Solution

by:
aheddell earned 300 total points
Comment Utility
If you are a beginner, use the SQL Management Studio - it saves you having to get the syntax right.

Start by performing a Transaction log backup - right click on the database, select Tasks and then Backup.  You should be able to work it out from there.  You may need to add a Device - its just a file to backup to.  You need to do this in order to release the transactions in the Transaction log on the theory that it may need them to restore the database to something sensible following a failure.

Then use the Shrink  option on that same Tasks menu.  I find it more effective to use the 'Files' option and select the individual file.

You can prevent the transaction log growing too much by scheduling a regular Transaction Log backup - maybe every 10 minutes, some databases need it more frequently.  This is good practise anyway as it allows you to restore more accurately in the event of a failure

Hope that helps

Thanks

Alex Heddell
0
 

Author Comment

by:paul-ashton
Comment Utility
Aheddell - Perfect! This is exactly the type of info I wanted!  Database is backing up as I type.  Thanks

Thanks to others who replied also.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now