Saturday, February 25, 2012

MS SQL 2000- Reduce transaction log size

The size of my transaction log file is out of control. I've backed up the database and the transaction log went from 120 GB to 120 MB. Now, I can't reduce the size of the transaction log file. It's still at 120 GB (w/ almost all of that being held as Free Space). I get errors when I try to manually reduce the file size. Any tips?How did you manually reduce the log size? Did you use DBCC Shrinkfile?|||Thanks for the reply! I hadn't tried DBCC Shrinkfile. So let's say I want to reduce the log file to 10 GB - would I do something like this (?):
DBCC Shrinkfile (LogFileName, 10000)|||See BOL regarding DBCC statements.|||I just tried DBCC Shrinkfile and got:

----------------------
Cannot shrink log file 2 (sde_log) because all logical log files are in use.
(1 row(s) affected)
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
----------------------

Any tips? Also, what's a BOL? is that like an FAQ?|||Sounds like you're dumping a lot of data without trying to control transaction size. If you're using BCP then use this switch:
-b<number_of_rows_that_would_be_viewed_as_1_transacti on>

If this "data dumping" is a reqular process, then along with "-b" and well sized trx log pre-allocated space you may probably get a good grasp on the log size and keep it under 1G.|||Thanks for the tips. I've been uploading an unusually large number of unusually large files to a spatial database in SQL. This level of traffic is not typical of this database.|||I just ran into this yesterday for the first time. I highligted the database on SQL EM, right-click and went to shrink the database. Click on file and VERY IMPORTANT: click down arrow on database file so the LOG is showing. (Example: Northwind_log) This will come in handy if you log grow anywhere near the one I have. It's over 1,000,000 records per month.|||HA!! That did it! Thanks, garrydawkins!|||You can do the same thing with a script by using DBCC SHRINKFILE. Here is an example from BOL:

USE UserDB
GO
DBCC SHRINKFILE (DataFil1, 7)
GO

This would allow you to automate your shrink as a job.

No comments:

Post a Comment