Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL 2000:  Shrink LDF file

Posted on 2016-08-31
11
Medium Priority
?
79 Views
Last Modified: 2016-11-29
Hi All,

I have a Windows 2003 Server running MS SQL 2000.  One of the databases log file is 160GB.

Whats the best way to shrink it?  And ideally stop it from growing over 50GB.

Its a virtual server, so doesnt have any SQL Backups currently setup.

MS SQL 2000

Many thanks
0
Comment
Question by:detox1978
[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
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 1000 total points
ID: 41778646
Are the transactions necessary?  EG: If you lost the DB in the middle of the day would you need to restore it up until that point?

If not you can set the recovery mode to simple, just make sure you take a backup every night so that  you don't lose work.
0
 
LVL 40

Accepted Solution

by:
lcohan earned 1000 total points
ID: 41778649
USE banndb
GO
CHECKPOINT
GO
DBCC SHRINKFILE (N'banndb_log' , 0, TRUNCATEONLY)
GO
-- or:
BACKUP LOG banndb TO DISK='NUL:'


what recovery mode is that DB in? if you click that options tab?
0
 
LVL 2

Author Comment

by:detox1978
ID: 41778653
I guess they are not needed.

Can I switch to simple (to reduce the size) then switch it back on (ideally with circular logging at 40GB)?
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 2

Author Comment

by:detox1978
ID: 41778662
The recovery mode is set to FULL
0
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 1000 total points
ID: 41778670
Just make sure you take a full backup first before clearing the log.  No need to change it if you want the log, just take the full backup, then do the truncate log.  You can then set the max filegrowth to 40000 MB.  Note that you'll get an error and won't be able to update if you go past the log size.
0
 
LVL 40

Expert Comment

by:lcohan
ID: 41778712
Sure you can if no business rule is asking for FULL recovery mode where you can take T-log backups beside FULL backup for faster recovery.
0
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 41778821
In SQL 2000, you don't even technically need to go to SIMPLE mode.

Just shrink the log (first), using the "BACKUP" command, then take a full backup immediately (or as soon as you reasonably can).

BACKUP LOG baandb WITH TRUNCATE_ONLY;

BACKUP DATABASE baandb TO DISK = '...' WITH ...;
0
 
LVL 2

Author Comment

by:detox1978
ID: 41778875
Hi Scott,

So do I run

BACKUP LOG baandb WITH TRUNCATE_ONLY;

Open in new window


then take a backup?  It's a virtual server, would a virtual snapshot be ok?
0
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 41778878
Yes, shrink the log, then take a full backup.  I'm not sure what specifically a virtual snapshot means on your server.  But however you normally take a full backup of your dbs.
0
 
LVL 2

Author Closing Comment

by:detox1978
ID: 41778940
Running the following reduced the size.

[code]USE baandb
GO
CHECKPOINT
GO
DBCC SHRINKFILE (N'baandblog' , 0, TRUNCATEONLY)
GO[/code]

Many thanks
0
 
LVL 2

Author Comment

by:detox1978
ID: 41906349
Hi All,


Sorry to be a pain.  But the server is running low on space again.  So I run the code below in query analyser on the server

USE baandb
GO
CHECKPOINT
GO
DBCC SHRINKFILE ('baandblog' , 0, TRUNCATEONLY)
GO

Open in new window


..and get the following...

SQL Results
Any ideas what I've done wrong / differently?

I've opened a new question for it here

Many thanks
D
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

715 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