Saturday, 16 February 2013

To Restore a Database from a backup on a network share

USE MASTER
-- ADD A NEW BACKUP DEVICE
--                       TYPE    NAME           PHYSICAL LOCATION
EXEC SP_ADDUMPDEVICE 'disk','networkdrive','\\W2k8.CONTOSSO.COM\AdventureWorks\AdventureWorks2008R2.bak'
 

-- EXECUTE THE RESTORE OPERATION
RESTORE DATABASE [AdventureWorks2008R2]
FROM  networkdrive
WITH  FILE = 1,    --Please configure these options as per your configuration
NOUNLOAD , 
STATS = 10, 
RECOVERY ,
MOVE N'AdventureWorks2008R2_Data' TO N'D:\AdventureWorks\AdventureWorks2008R2_Data.mdf', 
MOVE N'AdventureWorks2008R2_Log'  TO N'D:\AdventureWorks\AdventureWorks2008R2_Log.ldf'
 

-- DROP THE DEVICE
--                      Name         , Physical File (OPTIONAL - if present, the file is deleted)
EXEC SP_DROPDEVICE 'networkdrive'

No comments:

Post a Comment