Replacing MDF & LDF files from a tape backup

We have a database named 'lime' which became corrupt after a data import on Monday.

Path to the files is
E:\MSSQL Server\Data\MSSQL\Data\lime_Data.MDF
E:\MSSQL Server\Data\MSSQL\Data\lime_Data.LDF

I moved the lime_Data.MDF & lime_Data.LDF files to another location before restoring previous copy of the files from the image backup tape made on Friday into E:\MSSQL Server\Data\MSSQL\Data\

Now when use the SQL manager it shows lime(suspect). I tried putting back Modays files but still get the same 'suspect' mark on the database

Obviously moving the files and replacing them with previous ones has caused a problem. How can I get SQL to accept the files from Friday. (or any of the files!!)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Drop the database, create a new one with the same name and same files, stop sql server, overlay your database and log files, start sql server.
Hi hassalla,

I would be more tempted to use sp_attach_db to see if this works first, the example below creates a new copy of the pubs db from file copies of the mdf & ldf while SQL server is stopped:

sp_attach_db 'pubs3', 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs3.mdf', 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs3_log.ldf'

Essentially you can do exactly the same, but just try a different db name than your current db first like lime2.
more details about sp_attach_db here:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FYI you can also use sp_detach_db to drop the current suspect databases without deleting the underlying mdf and ldf files
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

I would guess either works.  BOL says:

sp_attach_db should only be executed on databases that were previously detached

which is the case here.
Melih SARICAOwnerCommented:

What kinda data import could drop a DB in to suspect statement ?


hassallaAuthor Commented:
some terms I don't recogise here
DROP - does this mean (dtm) DETACH?
BOL - ?
Hi hassalla,

BOL is books on line, MSSQLs online help, drop in the sense that mastoo has used it means 'delete', and 'damage' in the way non_zero has used it. Overlay as mastoo has used implies file copying the files over the top of the existing files.
hassallaAuthor Commented:
all is well now.
I used the
sp_attach_db 'dbname'
method to clear things up.

no doubt I will be back with more questions about SQL as it took me a while to figure out stored procedures and hot ot run them. RTFM might have helped me.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.