August 2, 2010 at 12:22 pm
Hi friends,
I've mdf(55GB) and ldf files to restore. I usually restore databases using backups but I've not done with the database files.. Do I just paste these files onto the local drive and attach the files to the database or how can I do it using the Management Studio? Please help me ..
Thanks so much
August 2, 2010 at 12:36 pm
You got it right. Just copy the files to the server and than attach the database using sp_attach_db:
EXEC sp_attach_db @dbname = <databasename>,
@filename1 = <full path name of mdf>,
@filename2 = <full path nameof ldf>
Gordon Pollokoff
"Wile E. is my reality, Bugs Bunny is my goal" - Chuck Jones
August 2, 2010 at 12:52 pm
Thanks Gordon.
Do I need to detach the database before I restore the files using sp_attach_db procedure? I tried to run sp_detach_db, I get 'cannot detach the database because it is currently in use'..
Any suggestions please?
Thanks again
August 2, 2010 at 12:56 pm
If the database already exists, you will need to first detach the current version before attaching the new files. In order to detach it, all current connections need to be terminated.
Gordon Pollokoff
"Wile E. is my reality, Bugs Bunny is my goal" - Chuck Jones
August 2, 2010 at 1:31 pm
Thanks..
ANother doubt, does the ldf file contain just the logs of the transactions from the source database? Asking because the ldf file is about 10GB.. Is it possible to restore just the mdf file and will the management studio create a new ldf file while attaching the database?
Thanks much
August 2, 2010 at 2:05 pm
newbieuser (8/2/2010)
Is it possible to restore just the mdf file and will the management studio create a new ldf file while attaching the database?
Maybe, but not necessarily.
The log is not an optional piece of the database that you can just throw away without consequence. It is not just a log of operations done. It's required for transactional consistency and durability.
Use both files for the attach.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply