SQL Server Performance Forum – Threads Archive
Attach a database without LDFI want to attach a database that one of the developers had detach it. The LDF file was deleted after detach. I tried to attach and rebuild the log file in SQL2005 using the following:
CREATE DATABASE [Test] ON
(FILENAME = N’G:MSSQLDataTest.mdf’)
I get the following error:
File activation failure. The physical file name "D:MSSQLDATATest_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 1Could not open new database ‘Test’. CREATE DATABASE is aborted. What should I do? Thanks,
you could try sp_attach_single_file_db Roji. P. Thomas
SQL Server MVP
Thanks for the reply. I used the following code and got the same result.
GO sp_attach_single_file_db N’Test’, N’G:MSSQLDataTest.mdf’
File activation failure. The physical file name "D:MSSQLDATATest_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 ‘Test’. CREATE DATABASE is aborted. CanadaDBA
Try using Managment Studio without selecting ldf. I don’t try that yeat but with EM 2000 work without problems and a new ldf is created.
SQL-Server-Performance.com All in Love is Fair
All postings are provided â€œAS ISâ€ with no warranties for accuracy.
Try CREATE DATABASE statement with ATTACH_REBUILD_LOG option…
In SQL 2000 you can use DBCC REBUILD_LOG command..which is in undocumented… In 2005 I believe you can ATTACH_REBUILD_LOG option…check BOL for more details… CREATE DATABASE pubs ON PRIMARY
‘Crogram FilesMicrosoft SQL ServerMSSQL.1MSSQLDatapubs.mdf’)
LOG ON (FILENAME =
‘Crogram FilesMicrosoft SQL ServerMSSQL.1MSSQLDatapubs_log.ldf’)
FOR ATTACH_REBUILD_LOG; MohammedU.
I believe Luis’s option should work with SSMS whereas EM used to have such issues. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.