Getting a database to attach from a My Document folder

Ever want to mount a database from your My Document Folder?  I do … far too often.  In this instance, my SQL Server database MDF file is in: C:\Users\crutkas\Documents\Visual Studio 2008\Projects\Bartender. 

Going into SQL Server Management Studio, and attaching a database will give you this issue.  As you can see, I can’t go in and use anything there.

image 

So what the issue is I have to give SQL Server’s user that is running under access to that folder!  You can do this a few different ways.  Give access to the SQL Server user to read the entire directory tree for your user (c:\Users\[user]\) or just that folder.

So how do you get the user that SQL Server is running under?  Use Computer Management to figure that out and go to the Services module.

image

image

For me, I’m running it under “Network Service”

Now I go back into either c:\Users\[user]\ or the target folder and get that user access.

image

If you did just the target folder, you’ll have to put in the entire file path in the file name of the Attach Database prompt, if you did the root, you now should be able to see everything via the folder tree!

No comments posted yet.

Post a Comment

Please add 2 and 6 and type the answer here: