If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > *_log.ldf became giant...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #16 (permalink)  
Old 09-16-02, 11:22
P Shuttleworth P Shuttleworth is offline
Registered User
 
Join Date: Sep 2002
Posts: 2
Re: *_log.ldf became giant...

Quote:
Originally posted by cutcopypaste
excuse me for posting again but this was one of the missing.

how can i shrink _log.ldf file? it is about 1,39 gb. thanks...
Make sure you back up your dayabase before you start and immediaetl after you finish. Use the following procedure:

Using Enterprise manager:

RH click on database required.

1 All Tasks: Backup Database

2 All Tasks: Shrink Database

3 All Tasks: Truncate Log

4 All Tasks: Backup database.

This will shrink you transaction log to your pre defined optione.
Reply With Quote
  #17 (permalink)  
Old 06-04-09, 01:26
rganesh rganesh is offline
Registered User
 
Join Date: Jun 2009
Posts: 1
Thumbs up Thanks a Lot!!!

Quote:
Originally Posted by varad01
Hi,

I replied for this some days back, but I dont know why the info. is missing here???

Here is the simple and Quick Solution. But the database will not be available for awhile.

Use detach and attachdb

1. First detach the database by using

Example : EXEC sp_detach_db 'pubs', 'true'

2. Delete the log file (or) To be safe ,Rename the log file to some name

3. Attach the database without log file.

EXEC sp_attach_db @dbname = N'pubs',
@filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
@filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'

Make sure the paths are correct.

When you attach without log file, the SQL Server will automatically create a log file with small in size , ithink it will be 1mb.

Try it . I will appreciate a response.

Have fun.

Varad01

Hi Varad01,
You are simply great man...
I was very tense since the *_log.LDF size was 34 GB.
I tried your steps and it create the *_log.LDF file automatically.
Great....
Thanks a lot once again..
Cheers..
Reply With Quote
  #18 (permalink)  
Old 06-04-09, 07:09
Enigma Enigma is offline
The SQL Apostle
 
Join Date: Jul 2003
Location: The Dark Planet
Posts: 1,394
Quote:
Originally Posted by varad01
Hi,

I replied for this some days back, but I dont know why the info. is missing here???

Here is the simple and Quick Solution. But the database will not be available for awhile.

Use detach and attachdb

1. First detach the database by using

Example : EXEC sp_detach_db 'pubs', 'true'

2. Delete the log file (or) To be safe ,Rename the log file to some name

3. Attach the database without log file.

EXEC sp_attach_db @dbname = N'pubs',
@filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
@filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'

Make sure the paths are correct.

When you attach without log file, the SQL Server will automatically create a log file with small in size , ithink it will be 1mb.

Try it . I will appreciate a response.

Have fun.

Varad01
Not a recommended approach ...

Shrinking the Log file is ideally done by taking a backup and then shrinking the file. Using a approach similar to this on your prod server might even cost you your job in case anything goes wrong

Ideal way to go about shrinking your log file
Code:
Use Master
 
dbcc sqlperf(logspace)
 
GO
The above code will give you log file size and the percentage of space actually used in the file. Ideally, you should be able to reduce any log file by the amount of space = 100-[Log Space Used%] * [Log Size (MB)]

SQL Server needs Log data only upto the point of the last log backup, the rest of the space is marked as reusable.

In case the recovery of your database is important to you, you may either take a full backup or a log backup.

You might want to take a look at the recovery model of the database, and the recovery model you actually need. In case, Transaction log backups are not being taken and all you are doing are full backups , you can set the recovery model to simple and this will free up log space in the file which you can then shrink.

Use
Code:
Use DBName
 
exec sp_helpdb DBName
To shrink the log file, you can then use
Code:
Use DBName
GO
DBCC SHRINKFILE(Filename, SizeInMB);
GO
Where filename is the name of the file (Not the actual filepath)
__________________
Get yourself a copy of the The Holy Book

order has no physical Brett in The meaning of a Kaiser . -database data
Reply With Quote
  #19 (permalink)  
Old 06-04-09, 09:33
PMASchmed PMASchmed is offline
Registered User
 
Join Date: Jun 2004
Location: Long Island
Posts: 696
Now, switch to simple recovery model, or create log dump jobs to manage log growth, if previous night's backup is sufficient for recoverability, switch db to simple recovery model, log will be truncated during checkpoint process (automatic), and this should not happen again unless you have some huge transaction occurring somewhere.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On