Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Emergency Action Needed

Author  Topic 

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-11-06 : 13:46:34
I have a database call it DatabaseA and
it has a .ldf file associated with that database on the c:drive which has 18Gigs. My network admin is telling me that this file in
C:\Program Files\Microsoft SQL Server\MSSQL\Data\DatabaseA_log.ldf

is taking up all the space on the C: drive. Please advise on proper course of action in order to reduce space and prevent further occurences. The database only has 40 Megs Of Data. It's being backed up using the full recovery model.




rharmon
Starting Member

41 Posts

Posted - 2002-11-06 : 13:49:26
Can you shrink the transaction log by right clicking on the database, selecting all tasks/shrink files?

Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-11-06 : 14:31:44
Thank You

Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-11-06 : 16:26:24
What is the recommended method for automating this process?

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2002-11-06 : 16:37:09
You could schedule a job to shrink it, but the first thing that I would do is move DatabaseA off the C drive. This is not the optimal location for a database.

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-11-06 : 16:38:29
I don't know about SQL 7.0, but 2000 allows you to set a schedule when you right-click and choose the Shrink Database feature.

Also look up DBCC SHRINKDATABASE and DBCC SHRINKFILE, you can put them into a T-SQL job step and set a schedule for the job.

Go to Top of Page

izaltsman
A custom title

1139 Posts

Posted - 2002-11-06 : 17:28:35
If you want to automate shrinking your data and log files, SQL Server does give you the "autoshrink" option (see sp_dboption in BOL)... However, since shrinking files is a resource-intensive process I strongly suggest that you try to investigate what might be causing your log to grow and perhaps find a way to prevent excessive log growth instead of relying on an "autoshrink" or a scheduled DBCC SHRINKFILE.

Your answer might be simply to increase the frequency of your log backups -- this will decrease the probability of log filling up, and if the log doesn't fill up, it won't need to increase the size of the log file! Also, look at any bulk operations that you might be running... Perhaps you can switch your db into bulk-logged recovery mode? That will help keep your log size under control as well. (Just be sure you understand the impact of changing the recovery model).

Edited by - izaltsman on 11/06/2002 17:45:11
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-11-06 : 18:29:53
I'm stuck with the full recovery model and currently there is a log backup every 15 minutes. The reason the log gets full is because every 15 minutes there is also a dts that refreshes 20-30 megs of data.

I think I will have to schedule a shrink job.

What is involved in moving the ldf file to another drive when it's been created, any heads up would be appreciated.

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2002-11-06 : 18:50:34
Just detach the database (this allows access to the files), move the files to the desired location, then attach the database. When you attach the database, be sure to specify the new location of the files.

Here is an example on how to move the pubs database:

EXEC sp_detach_db 'pubs', 'true'

--Move the files and change the path before you run the next command

EXEC sp_attach_db @dbname = N'pubs',
@filename1 = N'F:\MSSQL\Data\pubs.mdf',
@filename2 = N'F:\MSSQL\Data\pubs_log.ldf'

Detaching the database takes down the database, so be sure to do this during a maintenance window if this is a production system.


Go to Top of Page
   

- Advertisement -