Methods to Recover a SQL Database Without a Recent Backup: Step by Step Guide

Having a corrupt database and an outdated backup does not bode well. It could be that your most recent backup was undertaken many months ago and / or that the one and only copy of your database is now on a failed hard drive. Despite this, files which comprise of a SQL server database (known as .MDF and .NDF) frequently contain much more comprehensible information than anticipated even when they are faulty.

Below are different ways to repair a SQL database, listed by order of lowest to highest involvement.

Before You Start: Protect the Damaged Files

Further activity can compound an already flawed database, so first:

  1. Disconnect the database or prevent users from accessing it.
  2. Back-up the MDF, NDF and LDF database files onto another hard-drive or server.
  3. All recovery efforts should be undertaken using the back-up version, not the original database.

Common Signs of Database Corruption

  • Database status is either ‘Suspect’ or ‘Recovery Pending’.
  • Error messages such as: Msg 824, Msg 8939 and/or Msg 5172.
  • Problem attaching an .MDF file.
  • Inaccuracies and missing information.

Common reasons are electricity cut off mid-write; faulty hard drives; ransomware; upgrade interruption; and a full logging drive.

Method To Recover SQL Database

Method 1: Check for Backups You May Have Missed

Query the backup history in msdb:

SELECT database_name, type, backup_finish_date
FROM msdb.dbo.backupset
WHERE database_name = 'YourDatabaseName'
ORDER BY backup_finish_date DESC;

Type D refers to a full backup, type I is a differential and type L is a log backup. By combining an earlier full backup with a log chain you can usually identify the area near to the failure. Should the log be accessible, attempt a tail-log backup:

BACKUP LOG YourDatabaseName
TO DISK = 'D:\Backup\YourDatabase_tail.trn'
WITH NO_TRUNCATE;

This method is best for any case where a partial backup chain exists, not helpful if no backup was ever taken or the log is damaged too.

Method 2: Restore from Snapshots and Other Copies

Check for:

  • Hypervisor snapshots.
  • SAN/Storage snapshots.
  • Windows Volume Shadow Copy (Previous Versions).
  • Azure Blob storage and/or 3rd party backup agents.
  • Recently restored staging, reporting and test servers.

Test a restoration of any items within a test server and analyze against production.

This method is best for Virtualized or SAN-backed environments, but the limitation is that a snapshot taken mid-write can be inconsistent.

Method 3: Diagnose with DBCC CHECKDB and Fix Minor Corruption

DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;

This tells us the lowest level of repair that SQL Server believes is necessary. Should the problem relate only to a non-clustered index, then you can frequently repair it without any data loss:

ALTER DATABASE YourDatabaseName SET SINGLE_USER;
DBCC CHECKDB ('YourDatabaseName', REPAIR_REBUILD);
ALTER DATABASE YourDatabaseName SET MULTI_USER;

This method is best for minor index-level corruption, but the limitation that it can't fix damaged data pages, allocation structures, or system tables.

Method 4: Use Emergency Mode to Pull Out Your Data

ALTER DATABASE YourDatabaseName SET EMERGENCY;
ALTER DATABASE YourDatabaseName SET SINGLE_USER;

Alternatively, you can then import data using INSERT…SELECT, bcp or the Import/Export Wizard. Again, begin with the most important tables. This is data recovery. Unfortunately, it is time consuming and does not easily transfer stored procedures and triggers.

Note that REPAIR_ALLOW_DATA_LOSS is the most intensive of the built-in repair options. It can remove both data and even pages in order to effect structural repairs. It also disregards foreign keys and business rules. Further, there is no view of what will be repaired and no ability to roll back. Only ever execute this on a copy of your database having eliminated Methods 5 and 6.

This method is best for rescuing specific tables when the database won't open, but the limitation is the Time-consuming, and incomplete when corruption is widespread.

Method 5: Use Stellar Online SQL Repair

Apart from native commands and DBCC CHECKDB, Stellar Online SQL Repair is a fast way of assessing if your data can be salvaged. It can analyze and fix a damaged MDF file and is accessible via a web browser – no download or installation is required. Visit https://repair.stellarinfo.com/mssql/ to access this.

Key points to know:

  • No SQL server is required – the repair process takes place on Stellar’s systems. This means that even if your computer has no SQL server, the repair can still occur.
  • General issues. The platform repairs databases categorized as SUSPECT, those failing DBCC CHECKDB checks and databases affected by crashes, disk errors, MDF header and virus-related issues.
  • Unaltered source file. Repair is carried out in read only format and a new repaired version is produced.
  • Pre-download review. Within your browser, you can examine which tables can be recovered along with the number of tables.
  • Supported versions. SQL server 2005-2025 MDF files.
  • Data security. Files both sent to and repaired on the system are erased after 24 hours (Free) or 48 hours (Premium).

Plan

Price

File size limit

Download window

Free

$0

Up to 500 MB

24 hours

Premium

$99 per MDF file

Up to 5 GB

48 hours

Steps to Repair an MDF File Online

  1. Go to the Stellar Online SQL Repair website and select ‘Repair MDF File’.
  2. Log in and then add a copy of your MDF file.
  3. Allow time for the file to be analyzed and repaired. Generally, this takes around 15 minutes, although this will depend on both the file and extent of the damage.
  4. View and note details of the repaired tables in your browser.
  5. Select ‘Download MDF File’ to transfer the repaired file to your computer.

This method is best for small to mid-sized MDF files (up to 5 GB), quick checks, and machines without SQL Server, but it’s limitation is File size caps, one file per request, and uploading data off-site.

Method 6: Use Stellar Repair for MS SQL (Desktop Option)

If the data file is too big, if all database objects are required or if your company does not allow data to be uploaded then utilise the desktop version. This operates on your computer therefore the database will not be sent away from your premises.

In comparison to the web version, the desktop version allows:

  • Unlimited file size
  • Ability to repair an unlimited number of MDFs
  • Offline working and local storage for the repaired database
  • Restoration of tables together with views, stored procedures, triggers and indexes
  • Ability to view the repaired database for free prior to saving

The Corporate Edition costs $299. There is also a demo version available on the supplier’s website.

This method is best for large databases, full object recovery, and sensitive or regulated data, but the limitation is paid license required to save results, and recovery quality still depends on how much of the file is readable.

Final Thoughts

Not all data loss comes from an absence of backups. Safeguard your data and search for alternative backups. For simple repairs, utilize the in-built tools. To effectively repair more significant issues, use Stellar Online SQL Repair which enables quick online repairs (for files of up to 5GB). Upgrade to Stellar Repair for MS SQL to benefit from unlimited file size, full object repair and/or fully on-premises repair.

Frequently Asked Questions

1. Can I fix an MDF file using online SQL repair for free?

Yes, providing it is 500MB or smaller. Greater sizes require either the Premium (which allows 5GB) or desktop version, which has no file size restriction.

2. Is it safe to send my live database to an online SQL repair tool?

Whilst the online tool does automatically and securely remove files after 24-48 hours (depending on the version selected), there is still a network transfer involved. Therefore, if your data is subject to regulation or is particularly confidential, you may wish to check the online tool’s privacy policy with your IT security department. Alternatively, use a desktop version, such as Stellar Repair for MS SQL, which analyses files on your own computer.

3. How does the online version differ from the desktop software?

The online version recovers tables and rows and deals with one MDF file at a time. It also restricts files to 5GB for the premium subscription. Desktop software has no file size restriction and can analyse as many files as required. Alongside being offline, it can also recover extra database elements such as views, stored procedures, triggers and indexes.

4. Does a repair affect my original database?

According to Stellar, their online version operates in a read only format and generates a fresh repaired file without affecting the existing database. Nevertheless, in order to maintain a safety net, you should continue to repair a duplicate database, rather than the live version.

5. Can I repair a database in ‘Suspect’ mode without a backup?

In many cases, yes. A database enters ‘Suspect’ mode when SQL Server is unable to complete the recovery process – typically as a result of database corruption. Provided the MDF file remains on the hard drive it can be analysed by repair software. Firstly, make copies of the files. Next, carry out the repair. Finally, test the repaired database using DBCC CHECKDB.