We are creating a application which requires sql database as backend to store data. So when user install my application he chooses a sql instance and its details. There we plan to restore the database which is required for storing the users data etc.

So now if the user selects a sql instance of a another pc in the network then, how i should restore the database? Giving network path in backup database t-sql command is not a good idea. So in this cases how the database is restored to a network path? What is the best practice for this.


So are there multiple backups that may be selected? I'm having a hard time following that portion of the question.

If there are a large number of backups that you don't want to port with the application installation, then you would be storing them on a network share accessible by all client machines that would be installing your application. If there was only one backup, and it was reasonably sized, or multiple backups that are reasonably sized, why wouldn't you just have those ship with the installation?

Provided that's not an option, what you could do is create logic to first copy the backup file from the share to a local directory. Think of it like this:

  1. Copy backup file from "\yourShareName\Dir1\backup_file.bak" to "C:\Some\Local\Dir\backup_file.bak"
  2. Restore your database from the local copy of the backup file
| improve this answer | |
  • I have included backup file in my setup as they are small in size. So as u said i can copy to the backup file to PC(network pc with sql instance) and refer its local path in my restore database command? – IT researcher Oct 24 '13 at 14:23

Your file have to be located in a drive that the server can reach, meaning in your case that this should be a mapped network drive that the server has a access to

But you can access a file on a shared network resource by entering the file's location in UNC format(Universal Naming Convention)

You can use this especially if you don't have enough space on the machine, or if you just don't want to copy your file.

| improve this answer | |
  • 1
    but i dont want to give unc path for database. If share is removed then database cannot be accessed. – IT researcher Oct 29 '13 at 11:15
  • 1
    @ITresearcher Yes, this is true, the same is valid for mapped drive. But you cannot copy the file as well if sharing is removed. So in this situation, you have to opt for something and manage system in a way (if possible) that you establish the sustainable solution. Every solution mentioned here can work if some requirements are fulfilled – NikolaD Oct 29 '13 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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