Monday, March 26, 2012

LOG files

I have an SQL server with data files which have name_LOG.ldf files much much
bigger than the data files themselves.
How can I delete them or crunch them?
If I just delete them it appears that the data file can no loger be read.
Thanks,
Raul Rego
NJPIES
rrego.njpies.orgHi,
Dont delete, just shrink the file.
Steps to shrink the Log file.
1. Backup the transaction log (Use command:- BACKUP Log dbname to
disk='c:\backup\dbname.tr1' (or use enterprise manager) or (if you do need
the trasaction log backup execute below command)
backup log <dbname> with truncate_only
2. Indetify the log file for shrinking:-
use <dbname>
go
sp_helpfile
Based on the name column for the transaction log file execute the dbcc
shrinkfile
3. Shrink the transaction log file.
DBCC SHRINKFILE('logical_transaction_log file name','truncateonly')
Have a look into the below article,
INF: Shrinking the Transaction Log in SQL Server 2000 with DBCC SHRINKFILE
http://support.microsoft.com/default.aspx?scid=kb;en-us;272318
Thanks
Hari
MCDBA
"Raul Rego" <rrego@.njpies.org> wrote in message
news:eDV$K5hTEHA.3480@.TK2MSFTNGP11.phx.gbl...
> I have an SQL server with data files which have name_LOG.ldf files much
much
> bigger than the data files themselves.
> How can I delete them or crunch them?
> If I just delete them it appears that the data file can no loger be read.
> Thanks,
> Raul Rego
> NJPIES
> rrego.njpies.org
>|||> I have an SQL server with data files which have name_LOG.ldf files much
much
> bigger than the data files themselves.
Do you have any concept of recovery model? Do you ever back up your
database or transaction logs?
> If I just delete them it appears that the data file can no loger be read.
Yep, the log file is a pretty essential component of a SQL Server database.
http://www.aspfaq.com/2471
If you have no interest in data integrity or backups, you can set the
recovery model to simple, back up the log with truncate_only, then shrink
the file.
ALTER DATABASE database_name SET RECOVERY SIMPLE
GO
BACKUP LOG database_name WITH TRUNCATE_ONLY
GO
USE database_name
GO
DBCC SHRINKFILE(database_name_log, 1)
GO
--
http://www.aspfaq.com/
(Reverse address to reply.)

No comments:

Post a Comment