Have you ever tried to restore a database from a UNC filepath in SQL Server Management Studio? Out of the box, SQL Server doesn’t let you do it! I found this blog post () that shows you how and why mapped drives are not there.
Here’s the basic commands you need and what they do to enable network drives in your implementation:
- First we need to enable XP_CMDSHELL
- sp_configure ‘XP_CMDSHELL’ , 1
- Then we need to get the SQL session to map the network drive
- xp_Cmdshell ‘net use p: \\<<SERVER>>\<<MAPPED FOLDER>>’
- You should now see the drive in the GUI
Note: if you want to enable this on startup use the following command to create a stored procedure
CREATE PROCEDURE [dbo].[mapdriveonstartup]
AS
exec xp_Cmdshell ‘net use p: \\<<SERVER>>\<<MAPPED FOLDER>>’
go
Use this command to run the stored procedure on startup:
exec sp_procoption ‘mapdriveonstartup’,’startup’,’true’