Question : Question on Transaction Logs

I have inherited a server that is running SQL 2008 and the log files are huge for some of the databases.  The recovery model is set to FULL but transaction log backups are not happening. The disk is almost out of space.

I want to backup the transaction logs but if my disk is nearly full how can I do this?  Is it okay to back them up anywhere?

-ws

Answer : Question on Transaction Logs

Depending on how important your data is in the database.

If the data is not that important then simply truncate your database logs and go on with normal work otherwise if the data in the database is critical then I recommend the following:

Option 1: Make a full database backup first before shrinking your logs to the desired size.

If the above option is not possible then go for option 2 which is shrinking your logs and then backing up your database.

The last resort should be truncating your logs without backing up first as stated earlier.

Transaction logs are used in doing point-in-time recoveries: that is recovering your database to a certain time of the day if you want.

To shrink your log files, use the following syntax:

1. To get the file names, execute:  SP_HELPFILE

2. To shrink file, execute: DBCC SHRINKFILE('FILE_NAME', desired_file_size_in_MB);

e.g: dbcc shrinkfile('My_log_file', 50); -- will reduce the file size to 50MB.

To truncate the file, all u have to do is execute the following:

backup log [db_name] with truncate_only;

After all this is done, I recommend that you implement a maintenance plan which will backup your logs too so that they do not grow too big again.

Regards,

Chris Musasizi.

Random Solutions  
 
programming4us programming4us