您的位置:首页 > 数据库

Sql server restore script(还原数据库正确的步骤)

2012-10-17 16:56 387 查看
Database YourDB has full backup YourBaackUpFile.bak. It can be restored using following two steps.

Step 1: Retrive the Logical file name of the database from backup.

RESTORE FILELISTONLY

FROM DISK = 'D:BackUpYourBaackUpFile.bak'

GO


Step 2: Use the values in the LogicalName Column in following Step.

----Make Database to single user Mode

ALTER DATABASE YourDB

SET SINGLE_USER WITH

ROLLBACK IMMEDIATE


----Restore Database

RESTORE DATABASE YourDB

FROM DISK = 'D:BackUpYourBaackUpFile.bak'

WITH MOVE 'YourMDFLogicalName' TO 'D:DataYourMDFFile.mdf',

MOVE 'YourLDFLogicalName' TO 'D:DataYourLDFFile.ldf'


/*If there is no error in statement before database will be in multiuser

mode.

If error occurs please execute following command it will convert

database in multi user.*/

ALTER DATABASE YourDB SET MULTI_USER

GO
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐