April 18, 2013 at 1:31 pm
Hello,
What is the syntax on how to restore database on these requirement:
I need to run restore sql job from server 1,but the bakup file is on server2 and database where I need to restore is on server2
here is how I started
RESTORE DATABASE MyDatabase FROM DISK='E:\Backups\MyDatabase.bak'
Can anyone help me?
Thank you
April 18, 2013 at 1:35 pm
you can use a UNC path, assuming permissions for the network are in place:
RESTORE DATABASE MyDatabase FROM DISK='\\LOWELLSMACHINE\c$\SQLBackups\2008Backups\MyDatabase.bak'
Lowell
April 18, 2013 at 2:50 pm
Hi Krasavita,
I could not find any method to directly restore on another server through query. Probably you can use osql command utility from inside the job to get it done. Alternately, you can create a windows scheduled task on the server2 using osql commmand line to resotre on server2.
Seraj Alam
April 18, 2013 at 2:59 pm
i missed the part about restoring on the remote server.
if you have a linked server, i know you can do EXECUTE AT;
here's an example of creating a table on the remote server, you could change that to run the BACKUP command instead.
EXEC sp_addlinkedserver 'SeattleSales', 'SQL Server'
GO
EXECUTE ( 'CREATE TABLE AdventureWorks2008R2.dbo.SalesTbl
(SalesID int, SalesName varchar(10)) ; ' ) AT SeattleSales;
untested:
EXECUTE('RESTORE DATABASE MyDatabase FROM DISK=''E:\Backups\MyDatabase.bak''') AT SeattleSales
Lowell
April 19, 2013 at 6:56 am
Is there way maybe, to call sql job from another server and that job will have restore syntax?
Thank you
April 19, 2013 at 8:09 am
SP_START_JOB 'YourJOBname' will do it. also follow Lowell's instruction.
July 1, 2013 at 9:51 am
Can you just copy the backup file to a place that is accessible to the second server?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply