Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    6

    Unhappy Unanswered: Unable to attach database

    A co-worker deleted the log file to a database that was running. At that point the database showed as suspect and stopped running. I was able to detach the database but I am unable to attach the database. I get a msg stating the logfile cannot be found would I like to create a new one. I select yes. I get the following error.

    Error 1813: Could not open new database 'dbname'. CREATE DATABASE is aborted. Device activation error. The physical file name 'fullpath to the original log file' may be incorrect.

    Any suggestions would be appreciated.

  2. #2
    Join Date
    Apr 2004
    Location
    Kansas City, MO
    Posts
    734
    Look up sp_attach_single_file_db in Books Online.
    MeanOldDBA
    derrickleggett@hotmail.com
    When life gives you a lemon, fire the DBA.

  3. #3
    Join Date
    Feb 2004
    Location
    PAKISTAN
    Posts
    106
    If only the log file is lost for databse TEST for example, this may work.

    STOP SQL.
    Copy the data file to C drive.
    START SQL
    Query Analyzer:
    USE MASTER
    GO
    drop database test
    GO
    EXEC sp_attach_db @dbname = 'test' ,
    @filename1 = N'c:\test.mdf'

    A new log file would be created for the test db.


    Howdy!

  4. #4
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    IF the Log file .LDF is unavailable you must use SP_ATTACH_SINGLE_FILE_DB as referred by Derrick and refer to books online for further information.

    http://support.microsoft.com/default...b;en-us;271223 for information if you've multiple log files.

    HTH
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  5. #5
    Join Date
    May 2004
    Location
    Bolsover, Derbyshire
    Posts
    3
    You could try the following query:
    sp_attach_single_file_db 'Your_Database','C:\MSSQL7\Data\Your_Database.MDF'

    Obviously you need to change the Your Database and the location etc.

    Starb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •