Last active
March 15, 2017 07:58
-
-
Save jiimaho/3aa25944b576edab097ce9bdf223729e to your computer and use it in GitHub Desktop.
SQL Server restore database from network drive to external disk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- allow changes to advanced options | |
EXEC sp_configure 'show advanced options', 1 | |
GO | |
-- Update currently configured values for advanced options. | |
RECONFIGURE | |
GO | |
-- To enable xp_cmdshell | |
EXEC sp_configure 'xp_cmdshell', 1 | |
GO | |
-- Update currently configured values for advanced options. | |
RECONFIGURE | |
GO | |
EXEC xp_cmdshell 'NET USE G: \\network\path password /USER:domain\usrname' | |
USE [master] | |
RESTORE DATABASE [Name] FROM DISK = N'G:\name.bak' WITH FILE = 1, MOVE N'Name_Data' TO N'D:\Folder\Name.MDF', MOVE N'Name_Log' TO N'D:\Folder\Name_log.LDF', NORECOVERY, NOUNLOAD, STATS = 5 | |
GO | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment