Groups | Blog | Home
all groups > sql server new users > february 2005 >

sql server new users : Restore .MDF file



Sue Hoegemeier
2/24/2005 12:35:58 PM
Nope. The data files and log files work in pairs together.
First to delete the mdf, the database must have been offline
or the service was stopped. At that point, they would have
needed the log and data files from that point and time. I'd
guess they didn't pay much attention to anything about the
log...just restored an older mdf, copied that over and then
started the service. That's not really how you'd want to go
about it.
The best approach is to restore from a database backup.
If all they have is an mdf and ldf files, the best they can
hope for is to try to use sp_attach_db with a valid pair (or
set - you could have multiple files) of mdf, ldf files. Or
if they only have mdf files, they can try
sp_attach_single_file_db. But to use those, you really
should be explicitly detaching the files using sp_detach_db.
After you restore or attach...whichever...you'd want to run
a dbcc checkdb and dbcc checkcatalog on the database.
Sounds like they created a bit of a mess.

-Sue

On Thu, 24 Feb 2005 13:27:51 -0500, "Dave B"
[quoted text, click to view]
Sue Hoegemeier
2/24/2005 1:11:25 PM
Unfortunately, Dave posted that it's one of his clients so
he probably doesn't have much control over that. And some
companies have some procedures - such as the managers having
full access to everything people under them have - and
working up the hierarchy that way. At one place a manager
stopped a bunch of services and deleted database files
"because they were big files taking up too much room" after
receiving a notice from the operations group about space on
the server starting to get a little cramped. The manager had
full access to the server due to the position hierarchy
implementation of security. SOX and security focus in
general seems to be changing some of that.

-Sue

On Thu, 24 Feb 2005 14:41:27 -0500, "Steve Thompson"
[quoted text, click to view]
Dave B
2/24/2005 1:27:51 PM
I have a client who accidently deleted the MDF file for a SQL Server 2000
database. They restored the file from tape but now the log file shows the
database continuously restarting:

2005-02-24 10:09:42.24 spid55 Starting up database 'downs_IR'.
2005-02-24 10:10:17.24 spid55 Starting up database 'downs_IR'.
2005-02-24 10:10:52.24 spid55 Starting up database 'downs_IR'.
2005-02-24 10:43:39.16 spid53 Starting up database 'downs_IR'.

First of all, is it valid to just restore a missing MDF file? Are there any
steps she should have done after the restore. Thanks.


Steve Thompson
2/24/2005 2:31:00 PM
[quoted text, click to view]

Probably not the way you did this... Ideally, you'd want to restore the
database from the last good database backup, then apply the incremental
backups (if any).

[quoted text, click to view]

If you only have access to the mdf file, you could try dropping the above
database, then use sp_attach_single_file_db to reattach. Be sure to run DBCC
checks to check the health of the database.

Steve


Steve Thompson
2/24/2005 2:41:27 PM
[quoted text, click to view]

Excellent point, forgot to recommend that the users should be locked out of
the server on a file level!

Steve

Steve Thompson
2/25/2005 12:52:05 PM
[quoted text, click to view]

Sue,

You've got some great war stories!!! And, that is the sad reality, now if we
could only keep managers from having administrative rights.... <right>.

Steve

AddThis Social Bookmark Button