Click here to Skip to main content
15,922,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i am taking backup of database from remote server using smo but my problem is backup file is getting stored on remote machine.i want same backup file should be created on local machine instead of remote machine in C# using smo.

how can i achive this using smo in C#.

First, typically it's not a good idea to create a backup on remote computer. If this is just a single case, then fine. But if you're going to do this repeatedly what's going to happen for example in case of a network failure, you don't have a backup at all...

But to the answer. This can be done in numerous ways. The easiest way is direct the backup to remote computer is to use UNC paths. You can use them in the backup command or you can predefine a dump device. Te get more info, have a look at sp_addumpdevice[^] and especially example B.
Share this answer
RaviRanjanKr 6-Apr-11 15:00pm    
Nice Answer! My 5
Wendelius 6-Apr-11 15:33pm    
Thank you :)
SQL Server can only ever back up to a drive physically attached to the actual SQL Server machine. You cannot under any circumstances back up a remote SQL Server to your local harddisk - just not possible (neither in SMO, or in SQL Server Management Studio).

As a workaround you can make that your database call a command line program in the host, that send the file by ftp, copy it to some shared folder.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900