Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Server 2005 - Truncate/Shrink Log File

Posted on 2010-09-22
6
Medium Priority
?
636 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 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 400 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
Technology Partners: 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!

 
LVL 143

Assisted Solution

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

Accepted Solution

by:
aheddell earned 1200 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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 …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

885 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