sp_attach_db problem

  • Does anyone know how to reattach a db without a log file?  Somehow a user has deleted his log file but I do have the two data files. 

    Thanks

    Jules

    Jules Bui
    IT Operations DBA
    Backup and Restore Administrator

  • EXEC sp_attach_db @dbname= 'yourdatabasename',

    @filename1 = N'MSSQL\Data\yourdatabasename_data.mdf'

     

     

     

    Kindest Regards,

    Sameer Raval [Sql Server DBA]
    Geico Insurance
    RavalSameer@hotmail.com

  • use sp_attach_single_file, look it up in bol

  • it is still asking for a log file.  I think attaching a db w/o a log does not work, I have read past articles on it.

    Jules Bui
    IT Operations DBA
    Backup and Restore Administrator

  • If you attach through EM just ignore the log file and it will create a new log file in the same location as the mdf.

    I did have an issue once where this wouldn't work ( ever ) but I can't remember the cause or solution, sorry.

    Make sure there is no ldf with the same name from another database on the server

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

  • If there were uncommitted transactions or there was a rollback in progress, you might not be able to reattach without the log file.

    I detach databases, change the name of the log file and reattach in order to create a smaller log file.

    HTH,



    Michelle

  • You can do it by using DBCC REBUILD_LOG

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply