Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Restore Database from MDF file without LDF Expand / Collapse
Author
Message
Posted Thursday, May 19, 2005 6:21 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 30, 2005 4:45 AM
Points: 2, Visits: 1

I saw one Message posted by Mr. raino clearly explains about how to restore database only with the MDF file.But its showing error while executing the query.can u please reply me when you see this msg

Query I tried

dbcc traceon(3604)
dbcc rebuild_log ('Training','Training_Log')

=================Error================
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Server: Msg 5105, Level 16, State 2, Line 2
Device activation error. The physical file name 'Training_LOG' may be incorrect.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
========================================

Full Query you have posted
=============================================
shutdown sql

move the current database file or rename it

restart sql server

create a new database of the same name and log file and location as the old database and log file

get rid of the old database.
you may be able to right click delete it in this situation or used sp_removedb

create a new database of the right size and shape with correct log and data file locations

stop sql

rename the new databases.mdf or delete it if you don't have enough space - do not touch the .ldf

move back in the old database .mdf file or rename it back again

restart sql server

it should come up suspect
--------------------------------
1. From a query window, set the status so that you can update the system
tables by running the following query:
use Master
go
sp_configure "allow", 1
go
reconfigure with override
go

2. Then set the status of the DB that is giving you the problem (XXXXX) into
Emergency Mode by running the following query:

update sysdatabases set status = 32768 where name = '<DBName>'
go
checkpoint
go
shutdown with nowait
go

3. Go into the data directory (MSSQL7\DATA) and rename the log file associated
the DB in question (XXXX.ldf) to some
temporary name, such as XXXX.TMP.

4. Exit the query window.
5. Then start up SQL Server from a DOS command window by issuing:
sqlservr -c -T3608 -T4022.
6. Bring up another query window and verify that the DB is in emergency mode
by issuing:
select Name, Status from Sysdatabases where name = '<DB_Name>'

7. Verify that the status is 32768. If it is, then issue the query:
dbcc traceon(3604)
dbcc rebuild_log ('<DB_Name>','<log_filename>') <--- You will need
the quotation marks
REBUILD_LOG should take less than 5 minutes even on a very large
database. It should complete with the message
DBCC execution completed
8. Take the database out of bypass recovery mode by issuing the command
update sysdatabases set status = 0 where name = '<DBName>'
9. Exit the query window and then shutdown (Ctrl-C in the DOS window) and
restart SQL server. Verify the status of the
database by running DBCC NEWALLOC and DBCC CHECKDB on the database.
===============================================================

Post #183656
Posted Thursday, May 19, 2005 6:34 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, November 2, 2005 11:49 AM
Points: 2,611, Visits: 1

Try

dbcc rebuild_log ('Training', 'c:\Training_Log.ldf')

 




Post #183662
Posted Thursday, May 19, 2005 7:18 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 30, 2005 4:45 AM
Points: 2, Visits: 1

I have tried but its showing error.If try to open the created Database from enterprise manager its showing the error.Iam unable to expand the created Database

Post #183679
Posted Thursday, May 19, 2005 9:05 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, April 18, 2014 8:44 AM
Points: 1,148, Visits: 81

The information you posted looks somewhat dated (6.5 I'm guessing?).  What about simply using the sp_attach_single_file_db method described in Books On-Line?  One caveat:  attach single file will only work if the original database was shut down cleanly with no users or pending transactions.  But this seems a lot simpler and more straightforward than what you're trying to do. 

Hope this helps. 





My hovercraft is full of eels.
Post #183716
Posted Saturday, April 7, 2007 5:11 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, October 18, 2009 10:30 AM
Points: 2, Visits: 4

we have sql 2005 and cannot get these commands to work.  I have no idea what to next try.

 

same issues w/ database and log are not properly connected.

 

Post #356757
Posted Friday, February 8, 2008 11:13 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, January 22, 2014 2:58 PM
Points: 531, Visits: 965
Here is the situation:
> C drive containing the SQL server 2005 is gone
> D drive for data is available
> E drive for logs is GONE
> no backup of mdf nor the ldf file

current dondition:
> a new sql needs to be rebuilt
> the MDF files need to be restored

All the attach various commands are not the options because the DBs where shutdown ungracefully.
So, here is the Q.
How, to restore an MDF file on the new sql server without the original ldf file.
thx

JohnE


Cheers,
John Esraelo
Post #453380
Posted Friday, February 8, 2008 12:56 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, July 17, 2014 10:56 AM
Points: 3,924, Visits: 1,607
try this.

sp_attach_single_file_db @dbname= 'dbname' ,@physname= 'physical_name'


but, make sure database got only one .mdf file or say datafile. This command doesnot work with multiple data files.


SQL DBA.
Post #453421
Posted Tuesday, April 22, 2008 7:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, August 7, 2009 8:24 AM
Points: 4, Visits: 22
This should work.

Reinstall SQL 2005 at the same version level (SP1 or not).

Right click Databases....click attach.

Click Add and Point to MDF file.

Create new ldf file

Hit Ok.

You will then have to recreate any logins needed for that db in your SQL instance.

This is not very granular but I am running on empty for time. Good luck...this should work.
Post #488625
Posted Wednesday, May 7, 2008 11:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 8, 2008 5:27 AM
Points: 3, Visits: 15
I am getting following errro when executing:


DBCC REBUILD_LOG('dbname,'dbname_Log.LDF')

ERROR:
Server: Msg 5030, Level 16, State 1, Line 1
The database could not be exclusively locked to perform the operation.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

anyone have any idea why i am getting this locked error and how to resolve it.
my db got stuck now. can't do repeat the process either.

any answer greatly appreciate.



Post #496534
Posted Thursday, December 17, 2009 10:02 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 17, 2009 10:00 AM
Points: 1, Visits: 0
thanks brother i solve my problem. I am thankful to you from core of my heart. You r very Genius. May God you live long.
Post #835787
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse