Reputation: 27276
We have a service which runs on the SQL Server that performs database backups. The backups can be scheduled from a client computer, separate from the SQL Server. However, when browsing for a location to save the backup, the client needs to be able to browse the server's directories.
When using the Backup/Restore within SQL Management Studio, it does allow you to browse the server's file system. How can I make my application do this using SQL? Is that even possible?
Upvotes: 1
Views: 1132
Reputation: 1611
Yes, it's possible to access the host system by using batch commands via xp_cmdshell.
http://technet.microsoft.com/en-us/library/ms175046.aspx
Depending on the version of SQL you are using there are also additional commands such as xp_dirtree that can be used.
http://www.patrickkeisler.com/2012/11/how-to-use-xpdirtree-to-list-all-files.html
Upvotes: 2