It's always a failure to restore a database using BAK files in SqlServer20005 's Management Studio today!
Restore failed for Server ' Adandeli '. (MICROSOFT.SQLSERVER.SMO)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo
The backup set holds a backup of a database other than the existing ' AAA ' database.
RESTORE DATABASE is terminating abnormally. (Microsoft SQL Server, error: 3154)
Cannot find the reason (has selected "Overwrite the existing database"), can only use the command to restore, do not know why this.
--Returns a result set consisting of a list of databases and log files contained in the backup set.
--Main access to logical file names
Use master
RESTORE filelistonly
From DISK = ' g:\back. Bak '
Go
************************************************
/*
Recover database with Bak, Force restore (REPLACE)
STATS = 10 shows one record per completion 10%
Dbtest and Dbtest_log are above g:\back. The logical file in Bak
*/
Use master
RESTORE DATABASE DB
From DISK = ' g:\back. Bak '
With MOVE ' DBTest ' to ' E:\Program Files\Microsoft SQL Server2005\data\db.mdf ',
MOVE ' Dbtest_log ' to ' E:\Program Files\Microsoft SQL Server2005\data\db_log.ldf ',
STATS = ten, REPLACE
GO
++++++++++++++++++++++++++++++++
/*
Back up the data db to the. bak file. This bak file is then used to recover a new database dbtest.
*/
Use master
BACKUP DATABASE DB
to DISK = ' G:\DBBack0930.bak '
RESTORE filelistonly
From DISK = ' G:\DBBack0930.bak '
RESTORE DATABASE DBTest
From DISK = ' G:\DBBack0930.bak '
With MOVE ' DBTest ' to ' E:\Program Files\Microsoft SQL Server2005\data\dbtest.mdf ',
MOVE ' Dbtest_log ' to ' E:\Program Files\Microsoft SQL Server2005\data\dbtest_log.ldf '
GO
---******************************http://www.cnblogs.com/adandelion/archive/2006/09/30/519534.html
Restore DATABASE command restores SQL Server databases Bak