Skip to main content
SQL Server

SQL Server Management Studio – Mapped Drives

By June 1, 2014July 24th, 2018No Comments

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:

  1. First we need to enable XP_CMDSHELL
    • sp_configure ‘XP_CMDSHELL’ , 1
  2. Then we need to get the SQL session to map the network drive
    • xp_Cmdshell ‘net use p: \\<<SERVER>>\<<MAPPED FOLDER>>’
  3. 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’

Jason

Author Jason

More posts by Jason