In the premises, where MS SQL is used, error based situations do occur. Worth appreciable servers like SQL server can also pose indifferent scenarios in front of users for which one has to be prepared. Discussing about the error messages, one error message that often found is as follows:
SQL SERVER – Fix : Error Msg 1813, Level 16, State 2, Line 1
Could not open new database 'yourdatabasename'. CREATE DATABASE is aborted.
Before proceeding ahead, one should know the exact reason so that proper conclusion can be taken to resolve the matter. SQL error code 1813 mainly take place when damaged database log are attached to the new server.
SQL server log is corrupted and the foremost requirement is to rebuild the database so that it can be made operational.
USE MASTER
GO
sp_CONFIGURE 'allow updates', 1
RECONFIGURE WITH OVERRIDE
GO
SELECT *
FROM sysdatabases
WHERE name = 'yourdatabasename'
—-The statement will update only one row in database
BEGIN
UPDATE sysdatabases
SET status = 32768
WHERE name = 'yourdatabasename'
COMMIT TRAN
DBCC TRACEON (3604)
DBCC REBUILD_LOG(yourdatabasename,'c:\yourdatabasename_log.ldf')
GO
DBCC has two parameters-first it is database name and second is physical path of the log file. Ensure that path is physical otherwise, when you put logical name, an error message will appear.
sp_RESETSTATUS yourdatabasename
GO
USE MASTER
GO
sp_CONFIGURE 'allow updates',0
RECONFIGURE WITH OVERRIDE
GO
Given below will update only single row in the database
BEGIN
UPDATE sysdatabases
SET status = (value retrieved IN first query OF STEP 5)
WHERE name = 'yourdatabasename'
COMMIT TRAN
GO'
Note: While going through 8, 9, 10 steps if there is error while database is in use then set the database to status single user.
sp_DBOPTION 'yourdatabasename', 'single user','true'
Once you are over with 8,9,10 steps and you find that database is not in multi user mode then run this script.
sp_DBOPTION 'yourdatabasename', 'single user','false'
Note: If the steps mentioned above unable to provide help to resolve SQL error code 1813, then you have to look for some other way out. You can opt for external online utility to fix the problem.
With MDF recovery software, there are higher chances to retain back data by simple steps. The manual steps mentioned above have risk of losing data. Besides this, you have to be technically sound while following the manual steps to fix SQL error 1813.