Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to delete the log file

Posted on 2004-09-11
10
Medium Priority
?
6,556 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 1000 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

715 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