How to backup two databases and over write another

I have my production Database that I would like to backup and then restore the data to a "sandbox" database. The problem is that I the production database is not the same name as the sandbox database.

How would I solve this issue and be able to backup the production data and rename it to the sandbox database.

Thanks in advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Patrick BogersDatacenter platform engineer LindowsCommented:

Just restore the sandbox db and in the process point to the backup files from the production one.

Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
>> How would I solve this issue and be able to backup the production data and rename it to the sandbox database.

There is nothing like a database restored from a backup should be in the same name..
So, simply go and restore with whatever name you want in your sandbox database server..

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

but you need to make sure that you do not use the database name itself inside of any of the objects (SPs, UDFs, Views). So if there is something like "SELECT ... FROM ProductionDatabase.dbo.TableName" then of course you need to remove "Productiondatabase." from all these code lines as it is normally never needed to explicitly add the database name. This should be removed permanently, not only for the sandbox.

I recommend to use a tool like Redgate Search (free to download and install) which is able to search through all existing objects.


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

From novice to tech pro — start learning today.