Read time 4 minutes

Summary: The blog discusses fixing SQL database error 1813, caused by corrupted log files. It provides a detailed manual solution using SQL Server Management Studio. However, due to complexity, errors may occur. The blog suggests a professional tool, Kernel for SQL Database Recovery, as an alternative for secure data recovery.

In the previous month, we received numerous user inquiries concerning SQL database error 1813, which occurs when users attempt to attach their databases. The error message resembled something along these lines –

SQL SERVER – Fix : Error Msg 1813, Level 16, State 2, Line 1
Could not open new database 'databasename'. CREATE DATABASE is aborted.

After delving into the inquiries, we’ve formulated a set of recommendations to resolve SQL database error 1813. We’re eager to impart these insights to you via this blog.

The issue arises from the corruption of SQL Server’s log database files (LDF). We recommend employing a manual approach to reconstructing this log database file while in emergency mode.

Let us know the whole process in detail.

Manually Fixing SQL Database Error 1813

Attempting to resolve SQL database error 1813 on your own involves manually reconstructing the database through the SQL Server Management Studio. Share the essential steps needed to execute this solution.

  1. Generate a fresh database using Microsoft SQL Server Management Studio and ensure to save the database files (LDF and MDF) with the identical name as the original database that was impacted by the error.
  2. Next, stop all the running instances of the SQL Server.
  3. Move the initial MDF file to the recently established folder and substitute the original MDF file with the newly generated one. Additionally, remove the recently created LDF file from its designated folder.
  4. Now, start the SQL Server as an administrator. You would see that the database is in the SUSPECT mode.
  5. Run this script in the Management Studio to validate that master database system tables allow upgrading values.
    sp_CONFIGURE ‘allow updates’, 1
  7. After confirming, run this script to convert SUSPECT mode of current database to EMERGENCY mode.
  8. SELECT *
    FROM sysdatabases
    WHERE name = ‘databasename
    —-The statement will update only one row in database
    UPDATE sysdatabases
    SET status = <value>
    WHERE name = ‘databasename
  9. Now, close and restart the SQL Server.
  10. Open SQL Server Management Studio and reconstruct the log file using the identical name as the recently deleted log file from the newly established database.
  11. DBCC TRACEON (3604)
    DBCC REBUILD_LOG(databasename,’C:\databasename_log.ldf’)
  12. You need to reset the database status now with this script.
  13. sp_RESETSTATUS databasename
  14. Switch off the system tables value upgrade (performed in Step 6). Run:
    sp_CONFIGURE ‘allow updates’,0
  16. Set the database to the previous state
  17. Given below will update only single row in the database

    UPDATE sysdatabases
    SET status = (value retrieved IN first query OF STEP 7)
    WHERE name = ‘databasename
  18. If you still find error while performing the above steps, try changing database to single user mode.
  19. sp_DBOPTION ‘databasename’, ‘single user’,’true’

    Or come out of this mode using this command –

    sp_DBOPTION ‘databasename’, ‘single user’,’false’

Executing the aforementioned steps with precision has the potential to resolve SQL database error 1813, although it’s not a foolproof solution. The intricate and lengthy nature of the manual process increases the risk of errors, even for individuals with sound technical expertise. Additionally, in cases of severe corruption, this method may prove insufficient for resolution.

What should be the next step?

If you want to recover every bit of your SQL data without performing lengthy operations, then try a professional solution. In fact, we have it for you – Kernel for SQL Database Recovery. The tool operates autonomously to restore damaged SQL database files (MDF and LDF) to their original state, addressing all SQL Server errors. It enables users to access previously inaccessible objects and offers the option to save them to either Live SQL Server or a batch file. Additionally, users have the flexibility to choose their preferred destination after previewing the repaired data. Thus, this tool helps to open and view MDF files without SQL Server. All these features can be tested via the free trial version of the software. Later on, you can purchase the tool after seeing its working.


The blog guides users in resolving a prevalent SQL issue, specifically SQL database error 1813, through the process of rebuilding the database using Management Studio. Additionally, it highlights the efficacy of a robust third-party tool for securely recovering SQL databases.

Kernel for SQL Database Recovery