Solved

SQL 2000:  Shrink LDF file

Posted on 2016-08-31
11
45 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
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 250 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 39

Accepted Solution

by:
lcohan earned 250 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 250 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 39

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 69

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 69

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

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.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

773 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