Access Denied CREATE DATABASE LocalDB
Solution 1:
This error is due to a bug in the file creation path in SQL Express 14.0.100. Follow these steps if you are affected:
- Close SSMS and any running instances of SQL Server in Task Manager > Processes including SQL Server Telemetry and SQL Server Client NT related tasks.
- Navigate to %LocalAppData%\Microsoft\Microsoft SQL Server Local DB\Instances\ in Windows Explorer.
- Remove any local instances you installed like MSSQLLocalDB.
Open your favorite CLI (like Command Prompt) and use these sqllocaldb commands. If it says the commands cannot be executed because the instance MSSQLLocalDB does not exist, continue to the next step.
sqllocaldb stop MSSQLLocalDBsqllocaldb delete MSSQLLocalDBUpdate your locally installed SQL Server with the latest Cumulative Update https://www.microsoft.com/en-us/download/confirmation.aspx?id=56128. You can see an overview of updates in the Update Center for Microsoft SQL Server on Technet: https://technet.microsoft.com/en-us/library/ff803383.aspx.
After a succesful update, use the sqllocaldb create command.
sqllocaldb create "MSSQLLocalDB"Your CLI should prompt that it has created a localdb with version 14.0.300 or higher:
LocalDB instance "MSSQLLocalDB" created with version 14.0.3223.3.
If you successfully updated the local db instance but you are receiving this error after: SqlException: 'Cannot create file 'C:\Users\%USERNAME%\Database.mdf' because it already exists., please remove the file in the specified path and try again.
Solution 2:
I can't see the images due my shop's policies, but I think that you can achieve your goal in 2 ways.
In SSMS right click the server name and select properties, then go to "database settings" there's a section named "Database default locations" modify to meet your requirements.
As a second option is to specify the datafiles explicity like:
CREATE DATABASE [test]
ON PRIMARY
( NAME = N'test', FILENAME = N'c:\mypath\test.mdf' , SIZE = 8192KB , FILEGROWTH = 65536KB )
LOG ON
( NAME = N'test_log', FILENAME = N'c:\mypath\test_log.ldf' , SIZE = 8192KB , FILEGROWTH = 65536KB )
Post a Comment for "Access Denied CREATE DATABASE LocalDB"