Summary: Error 1813 message is one of the frequently observed errors in Microsoft SQL Server that may prevent you from opening the database. Read this blog to understand what causes the error and methods to fix the SQL database error 1813.
When trying to attach a SQL Server database, several users have reported about receiving SQL Server error 1813. The complete error message reads as:
Error Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘Database_Name’. CREATE DATABASE is aborted.
SQL Server error 1813 occurs when a damaged or corrupt database logs are attached to the new server.
When your SQL Server’s log is in a damaged state, try rebuilding the log to make the database healthy and operational. For this, perform the manual steps in the same sequence given below:
|Note: Rebuilding the log may result in data loss if the database did not shut down properly. If you don’t want to lose data, a better alternative is to use SQL repair software that can help repair the database files while keeping the data intact.|
USE MASTER GO sp_CONFIGURE ‘allow updates’, 1 RECONFIGURE WITH OVERRIDE GO
SELECT * FROM sysdatabases WHERE = Database_Name
BEGIN UPDATE sysdatabases SET status = 32768 WHERE name = 'Database_Name' COMMIT TRAN
Note: This step is a must, or else the SQL Server will encounter an error
Note: The name of this newly created log file should be kept the same as the LDF file that was recently deleted from the new database server.
DBCC TRACEON (3604) DBCC REBUILD_LOG(Database_Name, ‘C:\Database_Name_log.ldf ‘) GO
sp_RESETSTATUS Database_Name GO
USE MASTER GO sp_CONFIGURE 'allow updates', 0 RECONFIGURE WITH OVERRIDE GO
Note: If, while carrying out Steps 11, 12 & 13, there is an error while using the database, set the database to the single-user status.
sp_DBOPTION 'Database_Name' , 'single user' , 'true'
sp_DBOPTION 'Database_Name' , 'single user' , 'false'
With the correct execution of all these steps, the SQL Server error 1813 can be fixed. But, if the error persists, using a SQL database repair software from Stellar® may help.
Stellar Repair for MS SQL software can fix all types of corruption errors in SQL database files while maintaining database integrity. Essentially, the software helps to repair the corrupt database files and restores the database to its normal state in just a few clicks.
Note: If your database file is severely corrupt and the software is unable to detect the version of the db, you can select the database version manually from the following dialog box:
6. Enter the required information and save the repaired database file.
Now try opening the repaired SQL database file from your SQL Server account.
Damaged (or corrupted) database log file (LDF) can cause SQL error 1813. You can fix the SQL database error 1813 by rebuilding the log file following the manual step-wise instructions discussed in this blog. However, the manual process can be lengthy and time-consuming. It may also result in data loss. But, you can quickly fix the error by repairing corrupted db files with the help of SQL repair software, such as Stellar Repair for MS SQL. It helps repairs the corrupt database files and recovers all its objects, including tables, keys, indexes, stored procedures, etc.
Problem solver and Data recovery specialist. Usually share informative articles on data recovery, database corruption and ways to recover lost data.
Stellar Repair for MS SQL is an enterpriRead More
3-in-1 software package, recommended byRead More
Stellar Converter for Database is an effRead More
Powerful tool, widely trusted by users &Read More