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)
 need code to auto deal with log file

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2005-07-07 : 11:57:27
My db log file grew up so fast and I need truncate and shrink it once a week manyally.
Now, I like to setup job agent and auto do it once a week.
Can someone help me? What I used before is detach and attach db.
Can I use sp_dboption?

nr
SQLTeam MVY

12543 Posts

Posted - 2005-07-07 : 12:17:24
Why would you do that?
It will only grow again which is quite heavy on resources.

see
http://www.nigelrivett.net/SQLAdmin/TransactionLogFileGrows_1.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-07-07 : 12:32:48
Do not pass GO and go directly to SQL Server Books Online and read the entire section on Backing Up and Restoring Databases under Administering SQL Server. Pay close attention to transaction log backups which will truncate your t-log and is the only way to recovery to the point of failure.

Sean Roussy

Please backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own.

I am available for consulting work. Just email me though the forum.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-07 : 13:09:41
Sun, what is your recovery model set to? If FULL, are you performing regular transaction log backups? If not, then change the recovery model to SIMPLE if you don't care about point in time recovery. If you do care, then start performing tlog backups!

Tara
Go to Top of Page

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2005-07-07 : 13:27:44
I think I took the default. I'll change to simple.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-07-07 : 13:34:52
quote:
Originally posted by Sun Foster

I think I took the default.


That's a common mistake. Read nr's link for more information.

Tara
Go to Top of Page
   

- Advertisement -