3

I am trying to attach a database just from the MDF file, cause the server crashed and could never find the LDF. I am on a 2019 MS SQL Server. I am following the instructions from this page. I have created the database, took it offline and swapped my MDF and deleted the created LDF. Then put back online. When I run the following command I get the following:

UPDATE sysdatabases
SET status = 32768
WHERE name = 'MyDB'

Ad hoc updates to system catalogs are not allowed.

I ran the previous command without problems

USE MASTER
GO
sp_CONFIGURE 'allow updates', 1
RECONFIGURE WITH OVERRIDE
GO

Configuration option 'allow updates' changed from 0 to 1. Run the RECONFIGURE statement to install.

Furthermore, if I run the next command, I get the following:

DBCC TRACEON (3604)
DBCC REBUILD_LOG(Database_Name, 'g:\Program Files\Microsoft SQL Server\MSSQL15.AUS\MSSQL\Data\MyDB.ldf')
GO

DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Msg 2526, Level 16, State 3, Line 2
Incorrect DBCC statement. Check the documentation for the correct DBCC syntax and options.
Rick
  • 207
  • 2
  • 7
  • Consider this thread about attaching MDF without LDF. If you care about the data A LOT, you should hire some expertise and stop wasting your time with spam blogs. – SMor May 01 '20 at 21:25
  • I've tried that but get the error: The log cannot be rebuilt because there were open transactions/users when the database was shutdown, no checkpoint occurred to the database, or the database was read-only. This error could occur if the transaction log file was manually deleted or lost due to a hardware or environment failure. – Rick May 01 '20 at 21:35

2 Answers2

6

That is not an authoritative source. Please follow Paul Randal's process here, as he's the one who "decided to add a new feature to SQL Server 2005 called EMERGENCY-mode repair".

David Browne - Microsoft
  • 46,306
  • 3
  • 46
  • 96
0

Paul Randals's process will bring you DB online but there is good chances that you end up with a corrupted database.

Would be a better approch to simply restore the database from your backup (if you had backup).

Dominique Boucher
  • 3,118
  • 10
  • 22