cherriesh


hi,

if my transaction log is full, do i need to execute only this command to truncate old logs

DBCC SHRINKFILE(<dbname>, 1)

BACKUP LOG <dbname> WITH TRUNCATE_ONLY

DBCC SHRINKFILE(<dbname>, 1)

Should I use the same command as a daily maintenance to my transaction log

cherriesh




Re: transaction log is full

ColSchmoll


What recovery mode is your database in







Re: transaction log is full

cherriesh

Full recovery model.






Re: transaction log is full

ColSchmoll

By doing:

BACKUP LOG <dbname> WITH TRUNCATE_ONLY

You are essentually, invaliding the log. Do you not require the log backups for recovery purposes, in which case you should be backing up the log to disk, every X minutes. This will prevent you log from filling up.

If recovery on this base is not required then switch your recovery model to simple and it won't will up.






Re: transaction log is full

Madhu K Nair

Its all depends

(a) If you don't need FUll Recovery model change to SImple...

(b) If you don't take TL Backup change to simple recovery... IF you do... then increase the TL Backup frequency... you don't need to truncate the log then..

(c) Keep a good comfortable size for your TL so that system no need to allocate the space then you shrink it daily night.

I don't think you should do it daily... check all the above mentioned points and then decide

Madhu






Re: transaction log is full

cherriesh

Hi,

What if i want to retain it to Full Recovery Model. You mentioned about "increasing the TL backup frequency .... you dont need to truncate the log then." Do you mean that with this i need to execute the below command several times during my dts process just for log not to pile up Is this what you mean by TL backup frequency you mentioned that i dont need to truncate the log. But executing this statement will truncate my logs right Sorry, I'm just new to this stuff.

DBCC SHRINKFILE(<dbname>, 1)

BACKUP LOG <dbname> WITH TRUNCATE_ONLY

DBCC SHRINKFILE(<dbname>, 1)

Also, how can i modify the allocated space for my TL I want to change it to 5GB since it is set now to 2GB. I tried modifying it in the Database properties > Files. But I can't modify it.

cherriesh





Re: transaction log is full

Madhu K Nair

No... This command will truncate and shrink the file.. there are two issue when you do this

(a) The backup chain breaks. First step after truncating and shrinking the db should be Full Backup otherwise the TL backup chain breaks and the TL Backup becomes invalid

(b) System needs space for normal function and that too in Full recovery model the Inactive part of Log is not reused. System has to allocate space and its an overhead

If you take TL backup , then only you need full recovery model. What is the current frequency of TL backup (like every hour/two hour etc)

To take TL backup :

BACKUP LOG MyNwind TO disk='F:\yourTL.bak'

Refer this KB

http://support.microsoft.com/kb/873235

How to increase TL Size

ALTER DATABASE YourDatabaseName

MODIFY FILE

(NAME = YourDatbase_log,

SIZE = 5000MB);

Madhu







Re: transaction log is full

cherriesh

Hi,

I will set the frequency of the TL log backup to daily since this project is a data warehouse, and the dts runs only once a day. then after i execute the TL log backup, i will shrink the log file through DBCC shrinkfile. Then I will have a full backup of the database.

I have already altered the log file size up to 5000MB. When I checked the Database properties > Files, the mydb_log's initial size (MB) was changed to 5000.

I noticed another column which is the autogrowth and it's set to enable. (File Growth in Megabytes = 1; Maximum File Size Restricted File Growth (MB) = 2,097,152. If autogrowth is enabled upto 2GB and my log size just reached up to 700MB, i shouldn't have been prompted with "Transaction log is full" right

your response is greatly appreciated!

cherriesh





Re: transaction log is full

Madhu K Nair

You wrote

after i execute the TL log backup, i will shrink the log file through DBCC shrinkfile.

If you tuncating & shrinking the file daily , then no need to take TL before this process. That is of no use. Take a full backup soon after this process that is very important. Let the database be autogrowth enabled.. it gives flexibility, you don't need to monitor the space regularly

YOu can have altert which will fire when the log size is less than the some required size

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlops5.mspx

Madhu




Re: transaction log is full

cherriesh

Hi,

I will not do any truncate and shrink process before the Backup LOG. but i will do a shrink just after the Backup log is executed.

cherriesh





Re: transaction log is full

Madhu K Nair

Once you shrinked the TL all the TL backup taken before that is invalid... Ok no issue... if anything goes wrong in shrinking then you have TL backup to restore db.. But take full backup after shrink process that is very important

Madhu






Re: transaction log is full

ColSchmoll

If you're data is only changing once a day. Then why not put the base into simple model, take a full database backup weekly and a daily differential backup after your load process. I'm sure you'll find this more efficent.






Re: transaction log is full

mitani

Dear cherriesh,

i had the same problem and solved it.

the log is growing because of bulk copy of data. transactions are not deleted from log file at the end of importing data.

i used the same Microsoft KB article mentioned in a previous reply http://support.microsoft.com/kb/873235 and used the same commands as a daily scheduled windows task(batch file).

i have also configured sql to send me an email when size of log file is greater than 1GB, this way i can control the growth.

you could add at the end:

DBCC ShrinkDatabase(dbname)

P.S: you can leave the new size of the log and database blank.





Re: transaction log is full

ColSchmoll

Shrinking a database has both performance and fragmentation issues.