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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 95
  • Last Modified:

SQL 2000: Shrink LDF file

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
detox1978
Asked:
detox1978
  • 5
  • 2
  • 2
  • +1
3 Solutions
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
 
lcohanDatabase AnalystCommented:
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
 
detox1978Author Commented:
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
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!

 
detox1978Author Commented:
The recovery mode is set to FULL
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
 
lcohanDatabase AnalystCommented:
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
 
Scott PletcherSenior DBACommented:
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
 
detox1978Author Commented:
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
 
Scott PletcherSenior DBACommented:
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
 
detox1978Author Commented:
Running the following reduced the size.

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

Many thanks
0
 
detox1978Author Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now