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)
 DBCC SHRINKFILE

Author  Topic 

melcraig
Starting Member

39 Posts

Posted - 2006-07-11 : 17:20:08
I have a log file that is huge. I want to shrink the physical .ldf file. I have did a full backup.
Is this the correct command and I will not lose any data:

DBCC SHRINKFILE ('DBNAME', 'TRUNCATEONLY')

Thanks for your help,
Mel

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-07-11 : 17:21:08
What is your database recovery model set to? If FULL, are you performing regular transaction log backups? Do you require point in time recovery?


Tara Kizer
aka tduggan
Go to Top of Page

melcraig
Starting Member

39 Posts

Posted - 2006-07-11 : 17:23:05
It is set to full recovery and whomever set it up did not schedule dumps of the log files!

Melinda
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-07-11 : 17:33:10
If you don't require point in time recovery, then change the recovery model to SIMPLE. If you do require point in time recovery, then you must start backing up the transaction log. It will just grow and grow otherwise. Once you've either change the recovery model or started running tlog backups, then you can run the DBCC command.

Tara Kizer
aka tduggan
Go to Top of Page

melcraig
Starting Member

39 Posts

Posted - 2006-07-11 : 18:14:41
OK, I ran the script and now I can't delete the old transaction file .trn backup.
Any suggestions, it says it may be in use?
Thanks,Mel
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-07-11 : 18:17:46
If a file is in use, then you can not delete it. So you either need to kill the process that is accessing the file or reboot.

Hopefully you changed your recovery model to SIMPLE or are performing regular tlog backups now, otherwise this problem is going to occur again. We backup our transaction logs every 15 mintues due to the criticality of the data.

Tara Kizer
aka tduggan
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-07-11 : 20:53:36
i guess by now you've killed this already, but it is best to allow the job/task to finish to have a good backup before the truncate, otherwise ignore this post



quote:
Originally posted by melcraig

OK, I ran the script and now I can't delete the old transaction file .trn backup.
Any suggestions, it says it may be in use?
Thanks,Mel



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -