Solved

SQL Server 2005 - Truncate/Shrink Log File

Posted on 2010-09-22
6
631 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33732740
>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
ID: 33732748
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
ID: 33732840
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
Three Considerations for Containers

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read our article on Experts Exchange.

 
LVL 143

Assisted Solution

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

Accepted Solution

by:
aheddell earned 300 total points
ID: 33732937
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
ID: 33733188
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

628 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