How to Map Network Drive as Fixed Drive? – Interview Question of the Week #258

Question: How to Map Network Drive as Fixed Drive in SQL Server?

Answer: The command to map any drive as a fixed drive is Windows command and you can run that in the SQL Server with the help of the extended stored procedure. Here is the script for the same. Open a new query window in the SSMS and run the following command and it will map your network drive as a local drive to windows and you can use that to take your backup or store data/log files in SQL Server.

EXEC xp_cmdshell ‘net use <driver letter> \\<servername>\<sharename> /user:<username> <password>’

You can write the above statement as follows:

EXEC xp_cmdshell 'net use z: \\\shareddrive /user:YOURUSERNAME PASSWORD'

Once you run the above code it will map your shared folder share drive from the server to the local system as a Z: drive. It is a very convenient and popular method to map your share drive to local drive. I strongly suggest you bookmark this blog post.

This question came up recently in my Comprehensive Database Performance Health Check while helping one of the clients to move their database from one server to another server. I love little problems like this one as they are indeed a lot of fun to resolve.

Here are a few other blog posts which you may find interesting:

You can follow me at twitter here: @pinaldave

Reference: Pinal Dave (

Exit mobile version