Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is it possible to restore a database on a server, using a script on another server?

For example, I have a server A and a server B and I want to restore a database foo on server B from within a script on server A.
I was thinking of something like this: RESTORE DATABASE B.foo FROM DISK ..., but I can't find any information about it.

And I'm looking for something similar for BACKUP DATABASE too.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

No. Most commands are specific to the local server.

Saying that, if you have a linked server, you can do something like this:


Edit, after comments

You could also run EXEC MyLinkedServer.SomeDB.SomeSchema.MyRestoreWrapper ...

share|improve this answer
While reading documentation on OPENQUERY, I found that you can also execute a stored procedure on a linked server. So if I were to put my restore script in a stored procedure, this should have the same result? –  Stan Bruce Jun 1 '12 at 8:52
If the stored procedure was remote, yes –  gbn Jun 1 '12 at 9:02

Another option:

EXEC linkedserver.master.dbo.sp_executesql N'RESTORE DATABASE ...';
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.