Solved

SQL Server 2005 - Truncate/Shrink Log File

Posted on 2010-09-22
6
613 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]
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 142

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Select - column value lookup. 3 40
SQL find overlapping events (by time) 2 25
VB6 ListBox Question 4 30
Update data using formula 22 15
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

914 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

13 Experts available now in Live!

Get 1:1 Help Now