Jason Wong
Menu

Digital Products and Service Design

SQL Server Management Studio - Mapped Drives

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

· Jason Wong · 1 min read

  • Mapped Drives
  • SQL Server
  • SQL Server
  • SQL Server Management Studio

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>>&lt;<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>>&lt;<MAPPED FOLDER>>’

go

Use this command to run the stored procedure on startup

exec sp_procoption ‘mapdriveonstartup’,’startup’,’true’

Continue the conversation

If this perspective connects with a challenge you are working through, I would be glad to compare notes.

Get in touch