Solved

SQL 2000:  Shrink LDF file

Posted on 2016-08-31
11
68 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 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 40

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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

626 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