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

Posted on 2007-10-09
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
    LVL 16

    Expert Comment

    did you backup the database before you detached it?
    LVL 27

    Expert Comment

    Have you tried sp_attach_single_file_db
    LVL 27

    Accepted Solution

    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

    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

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now