Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Restoring a DB without a LOG File

Author  Topic 

mwoodward
Starting Member

3 Posts

Posted - 2007-07-27 : 10:47:02
I have tried unsuccessfully to attach a database that doesnt have its corresponding log file.

Is this possible in SQL 2005?

Please help.

Kristen
Test

22859 Posts

Posted - 2007-07-27 : 10:54:22
Have you tried the Single file attach procedure?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=single%20file%20attach,sp_attach_single_file_db

Kristen
Go to Top of Page

mwoodward
Starting Member

3 Posts

Posted - 2007-07-27 : 11:07:35
Yes.

None of this works, of course its probably me.

I tried:
EXEC sp_attach_single_file_db @dbname = 'Hospitals',
@physname = 'c:\temp\hospitals.mdf'
and get the following:

File activation failure. The physical file name "C:\Data\Hospitals_log.ldf" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'hospitals'. CREATE DATABASE is aborted.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-07-27 : 11:31:59
"The log cannot be rebuilt because the database was not cleanly shut down"

MDF file can only be reliably copied when the SQL Server Service is stopped (and was stopped by a clean shutdown, not just turning the power off!!), and thus not running.

Looks like this wasn't the case for this MDF file?

Kristen
Go to Top of Page

mwoodward
Starting Member

3 Posts

Posted - 2007-07-27 : 11:33:52
Correct.

I was installing IIS at the time and got the blue screen of death. I subsequently got my computer rebuilt, but only backed up the .mdf file and not .ldf file

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-07-27 : 13:19:36
I reckon you are out of luck then. Better to make a Backup file, rather than rely on a Detach / copy of the MDF file I'm afraid. And even then you can only be sure its OK by restoring and then performing a consistency check o the database (DBCC CHECKDB)

Kristen
Go to Top of Page
   

- Advertisement -