locked
cannot create db in localdb RRS feed

  • Question

  • Hi,

    I am getting the following error when trying to create DB in localdb from SQL Management studio:

    TITLE: Microsoft SQL Server Management Studio
    ------------------------------

    Create failed for Database 'aaaa'.  (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2100.60+((SQL11_RTM).120210-1917+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476

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

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

    ------------------------------

    A file activation error occurred. The physical file name 'aaaa.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
    CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5105)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2100&EvtSrc=MSSQLServer&EvtID=5105&LinkId=20476

    ------------------------------
    BUTTONS:

    OK
    ------------------------------

    I am connected as a local user, who is admin, uac is off. I am trying to create it through create db dialog, and have also tried through script and setting the path to example c:\aaaa.mdf, but get the same error. 

    Any help would be appreciated!

    Monday, May 14, 2012 9:30 PM

Answers

  • if you're using SSMS to create the database the SQL Server service account is used to access the file system and it is very likely that it does not have permission to the specified directory.

    Whe you're doing it from within VS or via LINQ than a different account is used - by the way VS is using SQL Server Express.

    Please check the default data file location within SSMS for the SQL server and check that the SQL Server service account does have full permission for the directory. If you don't specify the location of the database files the SQL Server does use the default data file location and the SQL Server service account should have the correct permission to access this directory and therefore the following code should usually work:

    CREATE DATABASE [aaaa]
    GO

    does the above code work on your system?


    Please use Mark as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    • Marked as answer by Stephanie Lv Wednesday, May 30, 2012 1:45 AM
    Tuesday, May 15, 2012 11:48 AM
  • Hi Robert Ivanc,

    Could you please post the T-SQL for creating database here?

    There is a thread with the same error, which is caused by the wrong filename, please see: Create Database :: ERROR. In addition, please make sure that the SQL Server service account has the write permission to target directory.

    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.


    Stephanie Lv

    TechNet Community Support

    • Marked as answer by Stephanie Lv Wednesday, May 30, 2012 1:45 AM
    Tuesday, May 15, 2012 2:37 AM

All replies

  • some further info: i can create db ok through visual studio 11 or even linqpad, just not through SQL Management studio.
    Monday, May 14, 2012 9:41 PM
  • Hi Robert Ivanc,

    Could you please post the T-SQL for creating database here?

    There is a thread with the same error, which is caused by the wrong filename, please see: Create Database :: ERROR. In addition, please make sure that the SQL Server service account has the write permission to target directory.

    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.


    Stephanie Lv

    TechNet Community Support

    • Marked as answer by Stephanie Lv Wednesday, May 30, 2012 1:45 AM
    Tuesday, May 15, 2012 2:37 AM
  • if you're using SSMS to create the database the SQL Server service account is used to access the file system and it is very likely that it does not have permission to the specified directory.

    Whe you're doing it from within VS or via LINQ than a different account is used - by the way VS is using SQL Server Express.

    Please check the default data file location within SSMS for the SQL server and check that the SQL Server service account does have full permission for the directory. If you don't specify the location of the database files the SQL Server does use the default data file location and the SQL Server service account should have the correct permission to access this directory and therefore the following code should usually work:

    CREATE DATABASE [aaaa]
    GO

    does the above code work on your system?


    Please use Mark as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    • Marked as answer by Stephanie Lv Wednesday, May 30, 2012 1:45 AM
    Tuesday, May 15, 2012 11:48 AM
  • When using LocalDb with SQL Server Management Studio a simple CREATE DATABASE [aaa] doesn't work. Any other options?

    Scott

    Friday, November 16, 2012 5:48 PM
  • It's been a while ago but here's my dime. This what helped me. There seems to be a issues between the default db location for localdb and what sql server manager is using. Set the file location for the database to c:\users\[user name]. It's explained in this post:

    http://www.stratospher.es/blog/post/error-creating-database-in-localdb-using-sql-server-management-studio-2012-ssms

    Thanks to Adam Hoffman

    Kind regards 

    Ryan


    Tuesday, January 15, 2013 3:24 PM