Tuesday, February 21, 2012

Restoring Database in TSQL

Hi. I want to restore a database named Employee Training but when I restore it, I want to name it Training. I know to to restore it in TSQL I type
"RESTORE DATABASE Employee Training To (name of device). How do I rename it to Training? I'd appreciate any help. Thanks.Have you looked in BOL (books online)? There is an example under RESTORE DATABASE - How to restore a database with a new name (Transact-SQL) that restores a copy of an existing database to another database with a new name.
I refer you here because you have to use the with move parameter to rename your physical mdf and ldf (and maybe ndf) files. If you have any more questions after you have read this, ask again.|||Restore the database first then rename it.|||I think then the question would have been "How do I rename a database?"|||Just give it the New name in the RESTORE command?

RESTORE myNewDBName ...|||Which is true and I referred to in post #2 with the BOL article and example cited, since they will have to move the physical filenames to a new file name for the restored database!

Lindalog, are you getting anything out of this?|||Which is true and I referred to in post #2 with the BOL article and example cited, since they will have to move the physical filenames to a new file name for the restored database!

Lindalog, are you getting anything out of this?
I'm getting it, you're right about having to move the physical filenames. Thanks for your help|||Thanks everybody. Tom53, I went to BOL and found exactly what I needed. Thanks alot. You saved me from hours of frustration. I'm sure that I'll be posting another question soon. Take care.

No comments:

Post a Comment