Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
xrum
Yak Posting Veteran
87 Posts |
Posted - 2012-01-27 : 12:04:49
|
Hi,I have a database backup that i need to move to a different SQL Server. I do not know the name of the database, when i go to "restore" it asks me what database i want to restore. This is a new database and not currently on the server. it will not let me go on. when i create a temp database and try to restore it with my .bak file, i get an error saying it contains database other then the one specified (tempDB)how do i restore a database on a new server from a .bak file? |
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2012-01-27 : 12:11:16
|
That's because tempdb is a standard system database in sqlserver, consider restoring it to a different nameDuane. |
|
|
xrum
Yak Posting Veteran
87 Posts |
Posted - 2012-01-27 : 12:14:01
|
i called it something else, but i got the error: the backup set holds a backup of a database other than the existing 'MY_TEST' database |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2012-01-27 : 12:25:53
|
You're using the GUI (SSMS) right?Ever use code to restore a database?SELECT @@SERVERNAME-- ***-- *** Make Sure the Server Name is -- ***-- Find the Database file to Restore. Make sure it's on the ServerEXEC master..xp_cmdshell 'dir \\servername\instance\path\*.*'-- Look at the internal file informationRESTORE FILELISTONLY FROM DISK = N'\\servername\instance\path\database.BAK' GO-- If the DB Exists, Kick everyone outALTER DATABASE [database] SET SINGLE_USER WITH ROLLBACK IMMEDIATEGO-- RESTORE The database...this will overlay an existing one, OR Create a new one if not in existence-- Get the Logical file names from filelistonlyRESTORE DATABASE [database]FROM DISK = N'\\servername\instance\path\database.BAK' WITH MOVE 'logical data file' TO '\\servername\instance\datafilepath\database.MDF' ,MOVE 'logical log file' TO '\\servername\instance\datafilepath\database_log.LDF' , REPLACEGOALTER DATABASE [database] SET READ_WRITEALTER DATABASE [database] SET MULTI_USERGO Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/ |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-01-27 : 14:19:11
|
quote: Originally posted by xrum i called it something else, but i got the error: the backup set holds a backup of a database other than the existing 'MY_TEST' database
That implies that a database called My_Test exists. Specify a name that does not already exist.--Gail ShawSQL Server MVP |
|
|
|
|
|