Avatar of Jason-
Jason-
 asked on

SQL Server 2012 Database Restore

I have a backup of a database called FOXVISUAL from a certain point in time. I want to restore this database on the server but I am changing the name of it to TESTVISUAL. I just want to look into this database and see some particular records and how they were at this point in time. I was always able to do this in SQL Server 2005 by doing a database restore pointing to the .bak file and changing the name of the destination to the new name and renaming the MDF and LDF. This way I would have my test database and my production database running on the same SQL Server. When I do this in 2012, I get a "Exclusive access could not be obtained because the target database is in use." To which the target database is called TESTVISUAL and does not exist. I am not sure how to acheive this.
SQLMicrosoft SQL Server

Avatar of undefined
Last Comment
Scott Pletcher

8/22/2022 - Mon
Nakul Vachhrajani

After changing the destination  database name, can you check if the restore wizard is trying to restore the DB over the same files as used by the primary database? If yes, you should change the target folder and file names that need to be used by your required destination  TESTVISUAL database.
Jason-

ASKER
I have the file names set to TESTVISUAL.MDF and TESTVISUAL_1.LDF in the Files section under the restore as field. It should not be trying to write over top the primary database.
ASKER CERTIFIED SOLUTION
Scott Pletcher

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Scott Pletcher

Once that runs, apply differential, if needed, and log backup(s) if needed, then do a final recovery on the db:

RESTORE DATABASE TESTVISUAL WITH RECOVERY;

And your db should be good to go!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy