Solved

How to delete the log file

Posted on 2004-09-11
10
6,554 Views
Last Modified: 2010-05-18
I want to delete the log file of a database but it says it cannot delete the mail transaction log.

From the SQL Analyzer y get a message that says that the log file is not available. It is 500GB in size.

How can I delete it or truncate it?
0
Comment
Question by:robrodp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 34

Expert Comment

by:arbert
ID: 12037154
You can NOT delete the log file.  You can truncate it doing something like this in query analyzer:

backup log YOURDATABASENAMEHERE with truncate_only
go
DBCC SHRINKFILE(YOURDATABASENAMEHERE_log,0)


Brett
0
 

Author Comment

by:robrodp
ID: 12037170
Thanks

Now I have this process and the log file starts growing and growing (takes about 28 hours, 500 million records) until there is no more disk space for the log file. Is there a way to process without the log file. I undertand de recovery issues. However it is importante to know
0
 
LVL 34

Assisted Solution

by:arbert
arbert earned 250 total points
ID: 12037187
Change the recovery model on the database to SIMPLE (right click on the database in enterprise manager, choose properties--its on the last tab).

500million records?  How are you inserting (bulk insert I would hope?)
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 34

Expert Comment

by:arbert
ID: 12037188
Oh my gosh, close some of your open questions!
0
 
LVL 5

Accepted Solution

by:
perezjos earned 250 total points
ID: 12037759
Hello,

Make a backup of your DB. Dettach the database. Delete the log file. Attach the database, this will recreate a new log file.

Jose
0
 
LVL 34

Expert Comment

by:arbert
ID: 12039162
"Make a backup of your DB. Dettach the database. Delete the log file. Attach the database, this will recreate a new log file."

You should never rely on this  method...SQL Server will NOT always recreate the LDF file.....
0
 
LVL 5

Expert Comment

by:perezjos
ID: 12039222
Hello,

robrodp glad you finally solved your problem. Thanks for the points.

arbert:

If a database comprises only a single data file and a single transaction log file, the database can be attached to an instance of  SQL Server without using the transaction log file, provided the database was cleanly shut down with no users and no open transactions. When the data file is attached, SQL Server creates a new transaction log file automatically.
The database must have been successfully detached from SQL Server using the sp_detach_db system stored procedure.
Single-file databases are useful .All the data is stored in a single file; attaching the single file to SQL Server automatically re-creates a transaction log so that the database can be used.

Jose





0
 
LVL 34

Expert Comment

by:arbert
ID: 12039392
"If a database comprises only a single data file and a single transaction log file, the database can be attached to an instance of  SQL Server without using the transaction log file, provided the database was cleanly shut down with no users and no open transactions. When the data file is attached, SQL Server creates a new transaction log file automatically. "

Yes in the perfect world--this isn't a good idea if you value your data....Look at all the questions on the site in which it DIDN'T recreate the log....Experience teaches....
0
 
LVL 5

Expert Comment

by:perezjos
ID: 12039807
Well, in this case it worked !


Thanks

jose


0
 
LVL 34

Expert Comment

by:arbert
ID: 12040164
Lucky for you
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question