Solved

SQL Server 2005 - Truncate/Shrink Log File

Posted on 2010-09-22
6
625 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Independent Software Vendors: 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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

762 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