Monday, March 12, 2012

Help needed to attach a DB

I detached a DB, now when I am trying to reattch it I cannot find the
data or the log file. I know I have not deleted anything from the
drives the only thing I am not sure exactly where they were located
prior to the dettach. This is on a test box but we still need to
restore the db. Is there anyway from system tables I could find where
the data file is. I looked for *.mdf files but cannot find the correct
.mdf file. Is it possiblefor the data file to have a differnt
extension? Is it possible for the data file to be located in any
network drive, I did not think this was possible in 2000 but I am using
2005 so I thought I should throw that out there ? Finally will it be
possible to restore the master db then look at the sysdatabse table and
see where it was located prior to the detach, i want to do this only if
it is possible to do so without effecting any other db's on this box.
Any ideas how to troubleshoot this, I am just baffled.
ThanksHi,
By default SQL 2005 uses MDF and LDF extension only. Once you detach the
database all the reference
for that database willl be moved from SQL Server. For me the only way to
identify the location is by restoring the Master database into a new SQL
Server 2005 instance. (Master can be restored only above a Master database i
n
single user mode). After resting execute the below query to get the
file location of the database you deleted.
select * from sys.master_files
Thanks
Hari
SQL Server MVP
"shub" wrote:

> I detached a DB, now when I am trying to reattch it I cannot find the
> data or the log file. I know I have not deleted anything from the
> drives the only thing I am not sure exactly where they were located
> prior to the dettach. This is on a test box but we still need to
> restore the db. Is there anyway from system tables I could find where
> the data file is. I looked for *.mdf files but cannot find the correct
> ..mdf file. Is it possiblefor the data file to have a differnt
> extension? Is it possible for the data file to be located in any
> network drive, I did not think this was possible in 2000 but I am using
> 2005 so I thought I should throw that out there ? Finally will it be
> possible to restore the master db then look at the sysdatabse table and
> see where it was located prior to the detach, i want to do this only if
> it is possible to do so without effecting any other db's on this box.
> Any ideas how to troubleshoot this, I am just baffled.
> Thanks
>|||Hi
If you have a backup of the database you could use RESTORE FILELISTONLY
command to get the file locations.
John
"shub" wrote:

> I detached a DB, now when I am trying to reattch it I cannot find the
> data or the log file. I know I have not deleted anything from the
> drives the only thing I am not sure exactly where they were located
> prior to the dettach. This is on a test box but we still need to
> restore the db. Is there anyway from system tables I could find where
> the data file is. I looked for *.mdf files but cannot find the correct
> ..mdf file. Is it possiblefor the data file to have a differnt
> extension? Is it possible for the data file to be located in any
> network drive, I did not think this was possible in 2000 but I am using
> 2005 so I thought I should throw that out there ? Finally will it be
> possible to restore the master db then look at the sysdatabse table and
> see where it was located prior to the detach, i want to do this only if
> it is possible to do so without effecting any other db's on this box.
> Any ideas how to troubleshoot this, I am just baffled.
> Thanks
>

No comments:

Post a Comment