Search
  • For Individuals
      « Back
    • Windows Data Recovery

      Recovers lost or deleted Office documents, emails, presentations & multimedia files.

      Free Standard Professional Premium

    • Mac Data Recovery

      Recovers deleted files, photos, videos etc. on Mac.

      Free Standard Professional Premium

    • Photo Recovery

      Recover photos, videos, & audio files from all cameras and storage on Windows or Mac.

      Free Standard Professional Premium

    • Video Repair
    • Photo Repair
    • iPhone Data Recovery
  • For Business
      « Back
    • Email Repair & Converter

      Repair for Exchange Converter for EDB Converter for OST Converter for NSF Converter for OST MBOX Repair for Outlook

    • Database & File Repair

      Repair for MS SQL Repair for Access Repair for QuickBooks Software Repair for Excel Extractor for Windows Backup Repair for MySQL

    • Data Recovery & Erasure

      Data Recovery Professional Data Recovery Technician Mac Recovery for Technician Virtual Machine Recovery File Erasure Software Mobile Erasure Drive Erasure File Eraser Software File Eraser Software for Mac

    • Toolkit

      Exchange Toolkit Outlook Toolkit File Repair Toolkit MS SQL Toolkit Data Recovery Toolkit

    • Forensic

      Email Forensic Exchange Auditor Log Analyzer for MySQL Log Analyzer for MS SQL

  • Store
  • Partners
  • Services
  • Offers
  • Support

 

  • For Individuals
    DIY software for anyone who works with data.

    Windows Data Recovery Recovers lost or deleted Office documents, emails, presentations & multimedia files

    Free Standard Professional Premium

    Mac Data Recovery Especially for Mac users to recover deleted documents and multimedia files from macOS

    Free Standard Professional Premium

    Video Repair Windows Mac Repair multiple corrupt videos in one go. Supports MP4, MOV & other formats.

    StandardPremium

    Photo Recovery Windows Mac Recover photos, videos, & audio files from all cameras and storage on Windows or Mac.

    Standard Professional Premium

    iPhone Data Recovery Windows Mac Recover deleted photos, videos, contacts, messages etc. directly from iPhone & iPad

    Recover Erase Toolkit

    Photo Repair Windows Mac Repair multiple corrupt photos in one go. Supports JPEG & other formats.

    Standard Professional Premium


  • For Business
    • Email Repair
    • Email Converter
    • File Repair
    • Data Recovery & Erasure
    • Toolkit
    • Forensic

    Exchange Repair Repair corrupt EDB file & export mailboxes to Live Exchange or Office 365

    Outlook PST Repair Repair corrupt PST & recover all mailbox items including deleted emails & contacts

    OLM Repair Repair Outlook for Mac (OLM) 2011 & 2016 backup files & recover all mailbox items

    Exchange Toolkit Repair EDB & Exchange backup file to restore mailboxes, convert OST to PST, & convert EDB to PST

    Active Directory Repair Repair corrupt Active Directory database (Ntds.dit file) & extract all objects in original form

    EDB to PST Convert online & offline EDB file & extract all mailbox items including Public Folders in PST

    OST to PST Convert inaccessible OST file & extract all mailbox items including deleted emails in PST

    NSF to PST Convert IBM Notes NSF file & export all mailbox items including emails & attachments to PST

    MBOX to PST Convert MBOX file of Thunderbird, Entourage & other clients, & export mailbox data to PST

    OLM to PST Convert Outlook for Mac Data File (OLM) & export all mailbox data to PST in original form

    GroupWise to PST Convert GroupWise mail & export all mailbox items - emails, attachments, etc. - to PST

    EML to PST Convert Windows Live Mail (EML) file & export mailbox data - emails, attachments, etc. - to PST

    Office 365 to PST Connect to Office 365 account & export mailbox data to PST and various other formats

    DBX to PST Convert Outlook Express (DBX) file & export all mailbox data - emails, attachments, etc. - to PST

    SQL Repair Repair corrupt .mdf & .ndf files and recover all database components in original form

    Access Repair Repair corrupt .ACCDB and .MDB files & recover all records & objects in a new database

    QuickBooks Repair Repair corrupt QuickBooks® data file & recover all file components in original form

    MySQL Repair Repair MyISAM & InnoDB tables and recover all objects - keys, views, tables, triggers, etc.

    Excel Repair Repair corrupt Excel (.XLS & .XLSX) files and recover tables, charts, chart sheet, etc.

    BKF Repair Repair corrupt backup (BKF, ZIP, VHDX and .FD) files and restore complete data

    Database Converter Interconvert MS SQL, MySQL, SQLite, and SQL Anywhere database files

    PowerPoint Repair Repair corrupt PPT files and restore tables, header, footer, & charts, etc. like new

    File Repair Toolkit Repair corrupt Excel, PowerPoint, Word & PDF files & restore data to original form

    Data Recovery Windows Mac Recover lost or deleted data from HDD, SSD, external USB drive, RAID & more.

    Technician Toolkit

    Tape Data Recovery Retrives data from all types and capacities of tape drives including LTO 1, LTO 2, LTO 3, & others.

    Virtual Machine Recovery Recover documents, multimedia files, and database files from any virtual machine

    File Erasure Permanently wipe files and folders, and erase traces of apps and Internet activity.

    Standard Corporate

    Mobile Erasure Certified and permanent data erasure software for iPhones, iPads, & Android devices

    Drive Erasure Certified and permanent data erasure software for HDD, SSD, & other storage media Windows Mac

    Exchange Toolkit 5-in-1 software toolkit to recover Exchange database, convert EDB to PST, convert OST to PST, restore Exchange backup, and reset Windows Server password.

    Outlook Toolkit Comprehensive software suite to repair PST files, merge PST files, eliminate duplicate emails, compact PST files, and recover lost or forgotten Outlook passwords.

    File Repair Toolkit Powerful file repair utility to fix corrupt Word, PowerPoint, and Excel documents created in Microsoft Office. It also repairs corrupt PDF files and recovers all objects.

    MS SQL Toolkit 5-in-1 software toolkit to repair corrupt SQL database, restore database from corrupt backup, reset database password, analyze SQL logs, & interconvert databases.

    Data Recovery Toolkit Software helps to recovers deleted data from Windows, Mac and Linux storage devices. Also supports recovery from RAIDs & Virtual Drives.

    Email Forensic Advanced email forensic solution for cyber experts to audit, analyze, or investigate emails & gather evidences.

    Exchange Auditor Exchange Server monitoring solution to automate audits, scans and generate reports ìn real-time.

    Log Analyzer for MySQL Analyze forensic details of MySQL server database log files such as Redo, General Query, and Binary Log.

    Log Analyzer for MS SQL Track & analyze MS SQL Server database transactions log files.

    Email Forensic
    STELLAR EMAIL FORENSIC

    Advanced email forensic tool to analyze and collect the mailbox data of email clients

    Learn More arrow


    All Products arrow

    All Products arrow

    All Products arrow

    All Products arrow

  • Our Partners
  • Lab Services
  • microphone-icon-android

    Trending Searches

    Data Recovery

    Photo Recovery

    Video Repair

    iPhone Data Recovery

    File Erasure Software

    Exchange Repair

    OST to PST

    PST Repair

    Raid Recovery

    MS SQL Repair

  • English Deutsch Français Nederlands Italiano Español 日本語 简体中文
  • Support
Database Recovery 5 minute read

How to Reconnect Log File to MDF File

Updated on April 22nd, 2021
Priyanka Chauhan
Written By
Priyanka Chauhan
Kuljeet Singh
Approved By
Kuljeet Singh

Summary: There can be several reasons that can cause corruption in a transaction log file (LDF). But the most common reason that can corrupt a log file is detaching and rebuilding the log file to reduce its size. Read on to know how you can reduce the size of the log file while preventing it from getting corrupted. If the log file is corrupt and the backup is not available, try using Stellar Repair for MS SQL software. The software repairs the SQL database MDF file. Once the file is repaired, you can create an LDF file from the repaired MDF file.

How to Reconnect Log File to MDF File

Contents

  • Introduction
    • Requirements
    • Getting started
  • The log files

Introduction

A common problem is to have the log file corrupt. This can be corrupt for many reasons:

  • A virus
  • A hacker attack
  • A power shut down or supply problem
  • A user malicious manipulation of the file
  • A user accidental manipulation
  • Human mistake or ignorance

In this article we will show what to do in case that your log file is corrupt and cannot connect to the database.

Requirements

The current article applies to SQL Server in any version, you will also need the SSMS which can be downloaded here:

  • SQL Server installer
  • SSMS installer

Getting started

The log file is corrupted for many reasons. When you disconnect and try to reconnect with the detach and attach features, your log file can be corrupted.

It is a bad practice to detach and rebuild the log file to reduce the size. Instead of that, you can shrink the file and use the recovery models according to your needs. First we will talk about the log files and then we will talk about recovery models and shrinking.

The log files

The transaction logs file are very important files that belongs to a SQL Server database. These logs store the database transactions and the database changes. It can be used to restore the database information. However, if it is corrupt, can corrupt the entire database. A common problem is that the transaction log file grows a lot and the users want to reduce the space used. Here you have some common advices to reduce the size in order to avoid a wrong manipulation:

Recovery model

You can reduce the information in the transaction logs, otherwise the space used by the transaction logs can be very high compared with the database files. You can control what information can be logged using the recovery model property.

Change the recovery model to reduce the information logged. The following options are available:

  • Full, that logs all the information with no exceptions.
  • Bulk logged is used when the bulk operations are applied. When bulk operations are made, the information logged is minimal.
  • Simple is used for minimal logged information. You cannot do log backups with this mode.

In order to modify the recovery model, you can use the Transaction SQL (T-SQL) or SSMS.

The following T-SQL code shows how to change the recovery model to full:

ALTER DATABASE Your-database SET RECOVERY FULL;

If you want to change to SIMPLE OR Bulk logged, use these commands:

Simple recovery:

ALTER DATABASE Your-database SET RECOVERY SIMPLE;

Bulk Logged:

ALTER DATABASE Your-database SET RECOVERY BULK_LOGGED;

You can also modify the recovery model in SSMS. To do that, right click the database and in Database Properties:

Stellar

Go to the Options page and select the Recovery model of your preference:

Stellar

Compress the transaction log file

Another way to shrink your transaction log file is to shrink your log file. The shrink operation will shrink your data. You can shrink the mdf file or log files.

In order to shrink a log file, use the following command:

DBCC SHRINKFILE (Yourlogfile_log, 1)

You may need to set to simple recovery model or backup the transaction file before shrinking.

Another way to shrink the log file is to use the SSMS.

In SSMS, go to Tasks>Shrink>Files

Stellar

In File type, select the Log file. Make sure to backup the transaction log first.

Stellar

Common errors

It is a bad practice to detach the database and try to attach rebuilding the log and remove the previous log file to reduce the space. This can be a problem and sometimes there are errors to rebuild the log file.

It is recommended to shrink the file or use the simple mode to reduce the space used. It is not really a good practice to use the simple recovery model, but you can temporary used in some scenarios.

If you do not need to recover data on a specific date and time using transaction log backups, a simple recovery model can be a good option.

What to do if the MDF file is corrupt

If the log cannot connect to the database, it may be possible that your MDF file is corrupt. In order to fix the MDF file corruption, you can use the SQL Recovery Software. Download the software from here:

free-download
  • The software will require the MDF file:
Stellar
  • Once selected the MDF file you can press the repair button.
  • The software will show a view of all the SQL Server objects:
Stellar
  • When you save the information, you can save in an MDF file in SQL Server, in Excel, CSV, HTML.
Stellar

If you select MDF the database will be restored and repaired.

Conclusion

The transaction log files store the SQL Server transactions of the databases. They can grow a lot and sometimes when we try to modify the size of the logs, the databases get corrupted.

Using the recovery model options can help you to control the size of the transaction log. For example, you can use the bulk-logged mode if you are doing a bulk copy of data.

Also, you can shrink the file to reduce the size. Detaching files, renaming them and rebuilding the log should be used in emergencies and not to reduce the size as a routine. Make sure to backup the logs (if your database is not in simple mode) and if your database is corrupt, you can always use Stellar Repair for MS SQL.

You may also be interested in How to Attach SQL database without LDF

About The Author

Priyanka

Priyanka is a technology expert working for key technology domains that revolve around Data Recovery and related software's. She got expertise on related subjects like SQL Database, Access Database, QuickBooks, and Microsoft Excel. Loves to write on different technology and data recovery subjects on regular basis. Technology freak who always found exploring neo-tech subjects, when not writing, research is something that keeps her going in life.

Best Selling Products

Stellar Repair for MS SQL

Stellar Repair for MS SQL

Stellar Repair for MS SQL is an enterpri

Read More
Stellar Toolkit for MS SQL

Stellar Toolkit for MS SQL

3-in-1 software package, recommended by

Read More
Stellar Converter for Database

Stellar Converter for Database

Stellar Converter for Database is an eff

Read More
Stellar Repair for Access

Stellar Repair for Access

Powerful tool, widely trusted by users &

Read More

1 comment

  1. Michael M. Rogers says:
    August 13, 2019 at 11:38 am

    hello,
    Before reading this blog, We had lost our hope with severely damaged MDF file. But, this software seems our last hope. Definitely, we will try this software asap.

    Reply

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *

53  −  44  =  

Table of Contents    arrow

  1. Introduction
    • Requirements
    • Getting started
  2. The log files

Categories

Related Posts

related post
Database Recovery

How to Fix Error “The database cannot be recovered because the log was not restored”?

Stellar Author Charanjeet Kaur April 15, 2022 Read More
related post
Database Recovery

How to Fix System Database Corruption in SQL Server?

Stellar Author Charanjeet Kaur April 8, 2022 Read More
related post
Database Recovery

How to Get Data from a Corrupt SQL Table?

Stellar Author Charanjeet Kaur March 4, 2022 Read More

Free Trial for 60 Days

Stellar Official Website

Stellar Data Recovery Inc.
48 Bridge Street Metuchen,
New Jersey 08840,
United States

ALSO AVAILABLE AT

Partner Logo

About

  • About us
  • Career
  • ISMS Policy
  • Privacy Policy
  • Terms of Use
  • License Policy
  • Refund Policy
  • End User License Agreement

RESOURCES

  • Blog
  • Articles
  • Product Videos
  • Knowledge Base
  • Case Studies
  • Whitepapers
  • Software Catalog

NEWS & EVENTS

  • News
  • Events

PARTNERS

  • Affiliates
  • Resellers
  • Distributors

Useful Links

  • Contact Us
  • Support
  • Special Offers
  • Student Discounts
  • Awards & Reviews
  • Downloads
  • Store
  • Sitemap
Follow Us

tw in yt

Stellar & Stellar Data Recovery are Registered Trademarks of Stellar Information Technology Pvt. Ltd. © Copyright 2022 Stellar Information Technology Pvt. Ltd. All Trademarks Acknowledged.

Hippa Logo tuv footer partner logo DMCA.com Protection Status
We use cookies on this website. By using this site, you agree that we may store and access cookies on your device Read More Got it!