收藏一个验证MS SQL SEVRER备份有效性的脚本

来源:互联网 发布:马云怎么靠淘宝挣钱 编辑:程序博客网 时间:2024/06/06 09:40
收藏一段不错的MS SQL SERVEWR检验备份数据库有效性的脚本:

USE MASTER
-- Add a new backup device
-- Ensure that the SQL Server can read from the physical location where the backup is placed
--                    TYPE      NAME   PHYSICAL LOCATION
EXEC SP_ADDUMPDEVICE 'disk','networkdrive','\\VPCW2K8\Database Backup\Test.bak'

-- Execute the Restore operation in VERIFY ONLY mode
-- Provide the actual paths where you plan to restore the database.
-- This is because VERIFYONLY also checks for available space
RESTORE
VERIFYONLY
FROM  networkdrive
WITH
MOVE N'TESTDB_DATA'    TO N'E:\TestDB\TestDB_Data.mdf', 
MOVE N'TESTDB_INDEXES' TO N'E:\TestDB\TestDB_Idx.mdf', 
MOVE N'TESTDB_LOG'     TO N'E:\TestDB\TestDB_LOG.ldf'

-- DROP THE DEVICE
--                   Name         , Physical File (OPTIONAL - if present, the file is deleted)
EXEC SP_DROPDEVICE 'networkdrive'
原创粉丝点击