Re: ldf file missing...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 02/16/05


Date: Wed, 16 Feb 2005 13:19:10 +0100


> new log file will be created and you can see the db in EM.

A new log file can only be created under certain circumstances:

1. Database was cleanly detached.
2. Database has only two files: one database mdf file and one log file.

If above two are not true, we are left to pure luck if sp_attach_single_file db work or fail. This
is clearly documented in Books Online. Andrea didn't mention whether both above conditions are
satisfied, so attaching cannot be expected to work.

For Andrea, best now it to restore from most recent backup. If that is undesirable, contact
Microsoft Support.

-- 
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Umut Nazlica" <UmutNazlica@discussions.microsoft.com> wrote in message 
news:DB0428CC-62F0-4E35-9C00-D9D385C9DCBF@microsoft.com...
> Are you sure that db is not attached?
>
> Did you refresh EM and see db is there.
>
> Create a db name TEST, and dettach the db, delete the log file.
>
> Try this: (You need the change the location regarding to your configuration)
>
> exec sp_attach_single_file_db
> @dbname = 'TEST',
> @physname = 'd:\Program Files\Microsoft SQL Server\MSSQL\Data\TEST_Data.MDF'
>
> You'll get:
>
> Device activation error. The physical file name 'D:\Program Files\Microsoft
> SQL Server\MSSQL\data\TEST_Log.LDF' may be incorrect.
> New log file 'd:\Program Files\Microsoft SQL Server\MSSQL\Data\TEST_log.LDF'
> was created.
>
> new log file will be created and you can see the db in EM.
>
> "Andrea Perrotta" wrote:
>
>> Hi all,
>> the transaction  log file  db_log.ldf (16 GB) is broken and now is missing.
>> on onther server i tried:
>>  exec sp_attach_single_file_db
>> @dbname = 'db_name',
>> @physname = 'db_name_data.MDF'
>> ....and this is the error:
>> ------------------------------------------
>> Server: Msg 1813, Level 16, State 2, Line 1
>> Could not open new database 'GLHP-IS'. CREATE DATABASE is aborted.
>> Device activation error. The physical file name 'x:db_log.LDF' may be
>> incorrect.
>> --------------------------------------------
>> I tried also to create a new DB with same name on same path for the devices
>> and
>> after detach this db and re-execute sp_attach_single_file_db with the old
>> "db_name_data.MDF"
>> and the new "db_name_log.LDF" and this is the new error:
>> ---------------------------------------------------
>> Server: Msg 5173, Level 16, State 1, Line 1
>> Cannot associate files with different databases.
>> Server: Msg 1813, Level 16, State 1, Line 1
>> Could not open new database 'GLHP-IS'. CREATE DATABASE is aborted.
>> Log file 'x:db_log.LDF'  does not match the primary file.  It may be from a
>> different database or the log may have been rebuilt previously.
>> ----------------------------------------------------------
>> I need HELP!
>> Andrea Perrotta
>>
>>
>> 


Relevant Pages

  • Re: How to attach db with missing log file?
    ... Start SQL Service ... Database fake will appear as suspect in EM ... I support PASS - the definitive, ... > allowing me to get past the missing log file, ...
    (microsoft.public.sqlserver.server)
  • RE: Shrink File?
    ... As my understanding of you problem, you have a database with a data file ... in the log file. ... You can truncate only nonactive portion of the transaction log. ...
    (microsoft.public.sqlserver.setup)
  • Re: PerfMon recording to SQL 2005
    ... seconds or even every ne second) from a busy server to a database on ... On the Perfmon counter Log Files tab, SQL Database has been set, End File ... Configuring the log file, choose the tested DSN as the System DSN ... The user account I created in SQL is an owner of the ...
    (microsoft.public.sqlserver.server)
  • Transaction log problems
    ... just before you backup the ... database change the recovery model to ... Simple, shrink the log file then change it back to Full, ... >transaction log and it is causing us some problems. ...
    (microsoft.public.sqlserver.server)
  • Re: sp_attach_single_file_db
    ... >I only have a MDF file not the log file and I used the following command ... CREATE DATABASE is aborted. ... > Device activation error. ...
    (microsoft.public.sqlserver.clients)