你的位置:首页 > ASP.net教程

[ASP.net教程]RESTORE DATABASE命令还原SQLServer 2005 数据库


--返回由备份集内包含的数据库和日志文件列表组成的结果集。--主要获得逻辑文件名USE masterRESTORE FILELISTONLY  FROM DISK = 'g:\back.Bak' Go************************************************/*利用bak恢复数据库,强制还原(REPLACE)STATS = 10 每完成10%显示一条记录DBTest和DBTest_log是上面g:\back.Bak里的逻辑文件*/USE masterRESTORE 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 = 10, REPLACEGO++++++++++++++++++++++++++++++++/*备份数据DB 到.bak文件。然后利用此bak文件恢复一个新的数据库DBTest。*/USE masterBACKUP 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 ---******************************