Professional Documents
Culture Documents
I have an old server with a defunct evaluation version of SQL 2000 on it (from 2006), and two
databases which were sitting on it.
6
For some unknown reason, the LDF log files are missing. Presumed deleted.
I have the mdf files (and in one case an ndf file too) for the databases which used to exist on
that server, and I am trying to get them up and running on another SQL 2000 box I have
4
sitting around.
sp_attach_db complains that the logfile is missing, and will not attach the database. Attempts
to fool it by using a logfile from a database with the same name failed miserably.
sp_attach_single_file_db will not work either. The mdf files have obviously not been cleanly
detached.
Share Improve this question edited Oct 8 '08 at 15:52 asked Sep 24 '08 at 11:29
Follow ConcernedOfTunbridge Jonathan
Wells 23.5k 12 62 81
59.8k 15 138 193
Step 1: Make a new database with same name, and which uses the same files as the old one
on the new server.
Step 2: Stop SQL server, and move your mdf files (and any ndf files you have) over the top of
the new ones you just created. Delete any log files.
Step 3: Start SQL and run this to put the DB in emergency mode.
Join Stack Overflow to learn, share knowledge, and build your career. Sign up
sp_configure 'allow updates', 1
go
go
go
go
Step 4: Restart SQL server and observe that the DB is successfully in emergency mode.
Step 5: Run this undocumented dbcc option to rebuild the log file (in the correct place)
DBCC REBUILD_LOG(TestDB,'D:\SQL_Log\TestDB_Log.LDF')
Step 6: You might need to reset the status. Even if you don't, it won't do any harm to do so.
Step 7: Stop and start SQL to see your newly restored database.
1 I also had to set it back to multi user mode afterwards as for some reason it ended up in restricted user
mode: ALTER DATABASE TestDB SET MULTI_USER
– ChrisWue
Mar 22 '13 at 8:13
In Enterprise Manager, right-click the server and choose Attach Database. Select the MDF file
and click Ok. It will then ask you if you want to create a new log file or not. Say Yes.
1
Share Improve this answer Follow answered Sep 24 '08 at 11:39
Valerion
821 8 14
Sadly, it still complains that "the physical file name blah.ldf may be incorrect." when I try this with a
badly detached mdf.
– Jonathan
Sep 24 '08 at 11:50
Highly active question. Earn 10 reputation in order to answer this question. The reputation requirement
helps protect this question from spam and non-answer activity.
Join Stack Overflow to learn, share knowledge, and build your career. Sign up