I have mapped a local folder as a drive, as follows:

subst E: c:\MyFolder

I need to create a database on that drive, but it fails:


Here is the error message:

Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\MyDb.mdf" failed with the operating system error 3(The system cannot find the path specified.).
Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

Restarting the service did not help at all. How can I have SQL Server create a database on the mapped folder?

Edit: why do I need this.

This database is a local Dev Edition sandbox to run automated tests against. Historically, we used to create such database on RAMDisk, so that tests run fast. Currently we are getting faster workstations with SSD drives. When everyone have them, we shall do away with RAMDisk altogether, and just create the sandbox on C: drive.

For now, while some team members still have to use RAMDisk, I'd like to create my sandbox on E: drive, without setting up RAMDisk. This is why I tried subst.

Can suggest a better approach?

  • Why can't you set up DB on c:\...? Why does it have to be hardcoded to `e:`? Eg. why not add a config param to your setup/deployment. – Remus Rusanu Nov 3 '14 at 15:59
  • When everyone have SSD drives, we'll definitely just use C:. For now, running tests off C: is too slow for devs without SSDs. Adding a configuration parameter is definitely an option. – AlexC Nov 3 '14 at 16:30

subst is scoped per session. Your command and the instance run on different sessions.

Creating a database on a subst virtual folder does not sound like a good idea. What are you trying to achieve?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.