It is currently Mon Jul 21, 2025 4:34 pm



Reply to topic  [ 2 posts ] 
Mounting SQL Server Databases without Log Files 
Author Message
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16701
Location: On a slope
Reply with quote
Post Mounting SQL Server Databases without Log Files
Yea, this probably won't matter to most of you guys, but whatever.

Basically, when you detach a database, you're supposed to have an mdf file (the database) and an ldf file (the transaction log). If you don't have the ldf, attaching the database again becomes problematic.

If there were no pending transactions when the database was detached, it's not too big a deal. Just attach the database, then in the datafiles section remove the ldf that it can't find. No big deal, though it actually took me awhile to figure that out.

However, if there were transactions happening when the database was detached, things get ugly. I found these instructions
Quote:
EXEC sp_resetstatus 'yourDBname';
ALTER DATABASE yourDBname SET EMERGENCY
DBCC checkdb('yourDBname')
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('yourDBname', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE yourDBname SET MULTI_USER


You can't mount it like above... it won't let you. So instead, you have to create a new database with the same name as the one you're trying to restore. You then stop SQL Server in services and replace the mdb of the new, empty database with your mdb. You then use the commands above to set it into emergency mode, then do a repair with data loss. Finally, you set it back to multi user mode.

Link to the original article
http://www.codeproject.com/KB/reporting ... abase.aspx

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Tue Feb 03, 2009 10:16 am
Profile WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16701
Location: On a slope
Reply with quote
Post 
the above post was altered due to incorrect instructions.

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Fri Feb 06, 2009 12:31 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.