Friday, March 23, 2012

Have an .mdf file but can't seem to attach it.

We had a server that was having all kinds of problems. We finally got it
booted and I copied the .MDF file off the hard drive. I'm trying to create a
new database on a different machine using this .MDF file and it appears to
not work. I had shut down SQL on the machine before I copied the file but I
didn't detach it ( didn't have the time and I was trying to explain it to
somebody else. ) So now I have this .MDF file that I can't attach. I'm doing
the following command:
use master
go
CREATE DATABASE BugTracking on (Filename='D:\Program Files\Microsoft SQL
Server\MSSQL\Data\BugTracking.mdf') for attach
go
and I'm getting the following error:
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'BugTracking'. CREATE DATABASE is aborted.
Msg 602, Level 21, State 50, Line 1
Could not find row in sysindexes for database ID 23, object ID 1, index ID
1. Run DBCC CHECKTABLE on sysindexes.
I've also tried to a direct attach deleting the log file and it won't do it.
Anybody have any thoughts?
TIA - Jeff.Can you try sp_attach_single_file_db and see if it works?
See:
http://msdn2.microsoft.com/en-us/library/ms174385(SQL.90).aspx
Adam Machanic
SQL Server MVP
Author, "Expert SQL Server 2005 Development"
http://www.apress.com/book/bookDisplay.html?bID=10220
"Mufasa" <jb@.nowhere.com> wrote in message
news:eH$ODo1sHHA.840@.TK2MSFTNGP03.phx.gbl...
> We had a server that was having all kinds of problems. We finally got it
> booted and I copied the .MDF file off the hard drive. I'm trying to create
> a new database on a different machine using this .MDF file and it appears
> to not work. I had shut down SQL on the machine before I copied the file
> but I didn't detach it ( didn't have the time and I was trying to explain
> it to somebody else. ) So now I have this .MDF file that I can't attach.
> I'm doing the following command:
>
> use master
> go
> CREATE DATABASE BugTracking on (Filename='D:\Program Files\Microsoft SQL
> Server\MSSQL\Data\BugTracking.mdf') for attach
> go
>
> and I'm getting the following error:
>
> Msg 1813, Level 16, State 2, Line 1
> Could not open new database 'BugTracking'. CREATE DATABASE is aborted.
> Msg 602, Level 21, State 50, Line 1
> Could not find row in sysindexes for database ID 23, object ID 1, index ID
> 1. Run DBCC CHECKTABLE on sysindexes.
>
> I've also tried to a direct attach deleting the log file and it won't do
> it.
> Anybody have any thoughts?
> TIA - Jeff.
>|||Sorry everybody - I finally figured out what was wrong - I was trying to
attach the file from a 2005 db into 2000. Once I switched to another server,
it worked fine.
J.
"Adam Machanic" <amachanic@.IHATESPAMgmail.com> wrote in message
news:E95832E9-C1D4-4BC3-B010-6F7079F2AEAF@.microsoft.com...
> Can you try sp_attach_single_file_db and see if it works?
> See:
> http://msdn2.microsoft.com/en-us/library/ms174385(SQL.90).aspx
>
> --
> Adam Machanic
> SQL Server MVP
> Author, "Expert SQL Server 2005 Development"
> http://www.apress.com/book/bookDisplay.html?bID=10220
>
> "Mufasa" <jb@.nowhere.com> wrote in message
> news:eH$ODo1sHHA.840@.TK2MSFTNGP03.phx.gbl...
>

No comments:

Post a Comment