Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL DB Restore

Posted on 2011-03-22
2
Medium Priority
?
534 Views
Last Modified: 2012-05-11
I have 2 databases (SERVICES and SERVICESTEST)

I need to restore the contents of SERVICESTEST into SERVICES.

I have made a backup of SERVICESTEST.BAK and I am trying to restore it over (with Overwrite box checked) and getting an error so I figure that I am doingit wrong.  

Before the restore, I changed the SERVICESTEST.BAK to SERVICES.BAK.

System.Data.SqlClient.SqlError: The file 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\SERVICESTEST.mdf' cannot be overwritten.  It is being used by database 'SERVICESTEST'. (Microsoft.SqlServer.Smo)


I am sure that there is a better way to resolve this.

This is version SQLServer 2008
0
Comment
Question by:yostnet
2 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 2000 total points
ID: 35188062
When overwriting, ensure that the file names you are overwriting are the test database and not the live one. In the options where you tick Overwrite the database, you will see a "Restore As" section in the list. Ensure you're overwriting the correct file. Close all SQL Management Studio windows you have open on that db as well.
0
 

Author Closing Comment

by:yostnet
ID: 35188071
got it thx
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
How to set-up an On Demand, IPSec, Site to SIte, VPN from a Draytek Vigor Router to a Cyberoam UTM Appliance. A concise guide to the settings required on both devices
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question