How would you bring back a SQL2005 database if the transaction log was deleted?

Posted on 2007-10-09
Medium Priority
Last Modified: 2010-03-19
Question: if you detached your database, stopped your SQL service, and deleted the transaction log file in SQL 2005, how would you be able to recover - or even bring the database back online?
Question by:wendelina
  • 2
LVL 16

Expert Comment

ID: 20044027
did you backup the database before you detached it?
LVL 27

Expert Comment

ID: 20044043
Have you tried sp_attach_single_file_db
LVL 27

Accepted Solution

ptjcb earned 2000 total points
ID: 20044057
Example (from BOL)
USE master;
EXEC sp_detach_db @dbname = 'AdventureWorks';
EXEC sp_attach_single_file_db @dbname = 'AdventureWorks',
    @physname = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf';

Can only be used with database with a single data file.

Author Comment

ID: 20044115
Create Database AdventureWorks
(Name=Adventureworks, file='C:\Program Files\Microsoft SQL Server\MSSQL.1\Data\AdventureWorks_Log.ndf
is another one we are going over.
thank you ptjcb.

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question