Saturday, February 25, 2012

Accidentally created new LDF, now get error with old LDF

Greetings all. I wanted to separate the MDF and LDF files. I am an SQL
newbie and here is what I did.
1. Detach MDF through right-click options
2. Move LDF to new drive
3. Attach MDF through right-click options
4. Path would not change for original LDF location and I hit OK by
accident (not sure how) but I did, and it created a new LDF in the
original location.
5. Detach MDF again
6. Attach MDF again
7. Manually typed path of moved LDF (the one I wanted to begin with)
and did not click verify (that always changed the location back to the
original). Just clicked OK and it took the path.
8. ERROR 5173 Cannot associate files with different databases
Any help would be greatly appreciated.
Regards,
GaryWhen you attached the db the first time it created a new log file and
adjusted the metadata to account for it. At that point the original log
file was no longer valid. So you should detach it and move the new log file
to the other location and attach that one.
Andrew J. Kelly SQL MVP
"Dreamer" <spencermountains@.yahoo.com> wrote in message
news:1134830448.181128.92340@.z14g2000cwz.googlegroups.com...
> Greetings all. I wanted to separate the MDF and LDF files. I am an SQL
> newbie and here is what I did.
> 1. Detach MDF through right-click options
> 2. Move LDF to new drive
> 3. Attach MDF through right-click options
> 4. Path would not change for original LDF location and I hit OK by
> accident (not sure how) but I did, and it created a new LDF in the
> original location.
> 5. Detach MDF again
> 6. Attach MDF again
> 7. Manually typed path of moved LDF (the one I wanted to begin with)
> and did not click verify (that always changed the location back to the
> original). Just clicked OK and it took the path.
> 8. ERROR 5173 Cannot associate files with different databases
> Any help would be greatly appreciated.
> Regards,
> Gary
>|||Thanks for the reply. Do I not need the original LDF file then? Have I
lost anything?|||Hopefully not<g>. When you detach the db it should commit or rollback all
transactions that haven't already been attended to. Before you do anything
like detach a db it is always a good idea to do a full backup first in case
anything happens and you need to get back to where you were. But in this
case you should be fine as long as the attach works with no errors.
Andrew J. Kelly SQL MVP
"Dreamer" <spencermountains@.yahoo.com> wrote in message
news:1134832357.374087.105070@.g44g2000cwa.googlegroups.com...
> Thanks for the reply. Do I not need the original LDF file then? Have I
> lost anything?
>

No comments:

Post a Comment