Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Restore Database from MDF file without LDF


Restore Database from MDF file without LDF

Author
Message
Shans
Shans
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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.
===============================================================


Allen Cui-55137
Allen Cui-55137
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2611 Visits: 1

Try

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





Shans
Shans
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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


sswords
sswords
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1148 Visits: 84

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.
Gerald Poe
Gerald Poe
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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.


John Esraelo-498130
John Esraelo-498130
Mr or Mrs. 500
Mr or Mrs. 500 (549 reputation)Mr or Mrs. 500 (549 reputation)Mr or Mrs. 500 (549 reputation)Mr or Mrs. 500 (549 reputation)Mr or Mrs. 500 (549 reputation)Mr or Mrs. 500 (549 reputation)Mr or Mrs. 500 (549 reputation)Mr or Mrs. 500 (549 reputation)

Group: General Forum Members
Points: 549 Visits: 1029
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
SanjayAttray
SanjayAttray
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3953 Visits: 1619
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.
Kevin LeClair
Kevin LeClair
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
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.
Bab
Bab
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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.



irfanadeem11
irfanadeem11
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search