Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I get multiple errors with LocalDB (startup error, can't create DB from SQL Server Management Studio and also multiple issues when trying to restore a backup) and none of the fixes I found are helping anything. It seems to me that all errors have their root in permissions not set up correctly.

Now a simple DDL table creation script works fine from SQL Server Management Studio and creates the database in the root of my user account's folder (as explained here). The Instances folder however (located at D:\Users\[My name]\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances despite when installing the SQL Server Express with Advanced Services I specified the DATA folder in another location - where only standard SQL Server Express .mdf files are stored, but not LocalDB instances) seems problematic regarding permissions (in contrary to the account root) therefore and also for having my DB files in a location among my projects I'd like to move the Instances folder to another place. Is this possible? I haven't even found a corresponding registry entry.

I'm using SQL Server Express 2012 and also SSMS of the same version (latest updates installed).

Any help would be appreciated.

Edit: The Database Settings page KookieMonster mentioned previously threw an error for me, not being able to edit nor see any configuration there. I let Windows Update check for updates again and there were some updates for SQL Server Express that weren't installed (although I'm sure I selected everything to install before), so I installed them. This made it possible for me to go to the settings page.

I've tried to set up the LocalDB instance's root folder to somewhere else but I get an access denied error for every folder I tried, namely

Alter failed for Settings 'Microsoft.SqlServer.Management.Smo.ObjectKeyBase'. (Microsoft.SqlServer.Smo)

------------------------------ ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

RegCreateKeyEx() returned error 5, 'Access is denied.' (Microsoft SQL Server, Error: 22002)

I get this even if the folder has Full control set for Everyone! Even more amusing the only folder that works, one that is set as a default (the user account's root) has no special permissions applied - just the ones my user has (just as any other folder I tried to set). In effect this means that all my LocalDB databases' files are saved to my account's root folder.

share|improve this question
What happens when you create a database and explicitly set the files to a specific location instead of taking the defaults? –  Aaron Bertrand Apr 7 '13 at 11:05
Thanks for your reply! That works (if I select a suitable folder like my project folder) but it's very inconvenient to have to specify the path every time. I just can't believe there's no way to change the defaults. –  Piedone Apr 7 '13 at 23:39
What happens when you go to the server node, right click, properties, database parameters and switch the default location? Are the values the one you set during the install or something else? –  KookieMonster Apr 8 '13 at 11:01
Thank you for the reply! Please see my edit. –  Piedone Apr 9 '13 at 15:37
I've been having the exact same problem. I think the reason changing folder permissions don't have an effect is because this is actually telling you there's a permissions problem with the registry, specifically creating a registry key (see the last part: RegCreateKeyEx). Unfortunately I can't figure out what key it wants to create. –  somedave Mar 20 '14 at 19:05

1 Answer 1

up vote 1 down vote accepted

See my comment above. I used Process Monitor to trace the registry access and found it was getting an Access Denied while trying to write:

3:16:40.8405491 PM sqlservr.exe 8756 RegCreateKey HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer ACCESS DENIED Desired Access: Write

I got around this by opening the Registry Editor and giving Everyone full access to HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer. Then I changed the default location and removed the Everyone access once it was done. This made the following extra keys that weren't there before:




share|improve this answer
Thank you. I've gone a different route in the end, so can't test how this would work for me. –  Piedone Mar 20 '14 at 20:07
I just tried exactly the solution you proposed here and yes I have got the extras you mentioned in the registry. Still this does not override or change the current properties values of my local database. The registry shows the desired values for all 3 locations, but in SMSS there are still the default locations by installation. Using MS sql server compact 3.5 SP 1 could be the reason for such a behavior? –  user3840527 Jan 11 at 10:31
This is the only place that I've been able to find any info about this error. somedave, yes, altering the permissions for that reg key does make the error go away, but as user3840527 says, SSMS still has the original default locations afterwards, even after exiting & reopening it. –  Yann Duran Jan 30 at 6:36
@Piedone, could you please possibly explain what is was that you did instead of using the reg key method? Or point to somewhere that explains the method? Thanks –  Yann Duran Jan 30 at 6:38
@YannDuran I will disappoint you but I didn't go with LocalDB in the end... Due to these errors I abandoned using it and now I'm just running full DBs in SQL Server Express. –  Piedone Jan 30 at 11:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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