Solved

SQL 2000:  Shrink LDF file

Posted on 2016-08-31
11
49 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Suggested Solutions

Title # Comments Views Activity
Are triggers slow? 7 11
SQL Quer 4 21
What is the best way to use power bi and ssrs 3 23
Finding gaps or missing dates in a date range using TSQL 3 24
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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 set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
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.

856 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