Fix CREATE DATABASE Permission Denied Error

“CREATE DATABASE permission denied in database ‘master’” means your current SQL Server connection does not have permission to create a database. Fix it by using an authorized login, having an administrator grant the required permission, or connecting to an existing database provided for you. Before changing permissions, check which server and identity are actually handling the failed request.

Use the symptom to choose the right starting point:

Symptom Likely Cause Appropriate Fix
Creating a database fails in SSMS The connected login lacks database-creation permission Verify the login, then request a narrowly scoped permission grant
Database creation works in SSMS but fails in an application The application uses a different identity, instance, or database name Check the application’s actual connection configuration
A deployment script fails on shared hosting The provider supplies an existing database but restricts database creation Deploy the schema into the assigned database
A database appears despite a “Create failed” message A later statement or configuration action failed Identify the failing statement before retrying
The error mentions directory lookup, a missing path, or operating-system access Database-file configuration is failing Check server-side paths and the SQL Server service account’s access

What the Permission Error in ‘master’ Means

SQL Server separates server logins from database users. A login connects to the instance; a database user controls access within a particular database. Being able to connect, query tables, or administer an existing database does not automatically authorize creating another database.

The error names master because it is a system database involved in database creation and instance-level information. It does not mean SQL Server is trying to put your application’s tables inside master.

Two distinctions matter:

  • db_owner is a database role. Membership in an application database does not grant permission to create other databases.
  • dbcreator is a fixed server role, not db_creator. It allows creating, altering, dropping, and restoring databases, so it is broader than a simple creation permission.

Changing the query window’s database to master does not give your login additional privileges.

How to Fix CREATE DATABASE Permission Denied in ‘master’

For SQL Server, including local development instances, and Azure SQL Managed Instance, verify the failing connection, check its database-creation permissions, and use an approved identity to provision the database. Azure SQL Database and restricted hosting require different handling.

The example database and login names below are placeholders. Replace them with your intended database name and an existing, approved provisioning login.

Step 1: Confirm the Server and Login Behind the Error

  1. Open a query window using the connection that fails.
  2. Run this diagnostic query:
SELECT
    SERVERPROPERTY('ServerName') AS connected_server,
    SERVERPROPERTY('Edition') AS sql_edition,
    ORIGINAL_LOGIN() AS original_login,
    SUSER_SNAME() AS execution_login,
    DB_NAME() AS current_database;
  1. Compare connected_server, original_login, execution_login, and current_database with the server, identity, and database you intended to use.

ORIGINAL_LOGIN() identifies the login that established the session. SUSER_SNAME() helps reveal whether the current execution identity differs, such as through impersonation.

For an application failure, testing only your personal SSMS connection is not enough. Inspect the application’s effective connection configuration and, where possible, run the diagnostic through its connection.

Check especially for:

  • A different named instance on the same computer.
  • Windows authentication running under a service identity.
  • A SQL authentication username different from your SSMS login.
  • An environment variable overriding the expected database name.

If the connection is wrong, correct it, reconnect, and retry the intended operation before changing any permissions.

Step 2: Check Effective Database-Creation Permissions

  1. Run this query in the failing SQL Server connection to check database-creation permissions and membership in dbcreator and sysadmin:
USE [master];
GO
SELECT
    HAS_PERMS_BY_NAME(
        NULL, NULL, 'CREATE ANY DATABASE'
    ) AS can_create_any_database,
    HAS_PERMS_BY_NAME(
        NULL, NULL, 'ALTER ANY DATABASE'
    ) AS can_alter_any_database,
    HAS_PERMS_BY_NAME(
        N'master', N'DATABASE', N'CREATE DATABASE'
    ) AS can_create_database_in_master,
    IS_SRVROLEMEMBER(N'dbcreator') AS is_dbcreator,
    IS_SRVROLEMEMBER(N'sysadmin') AS is_sysadmin;
  1. Interpret permission results of 1 as available and 0 as unavailable. A NULL result is inconclusive, not confirmation of permission.
  2. Give these results to the administrator if creation remains blocked.

SQL Server accepts several authorization paths for creating a database, including CREATE DATABASE in master, server-level CREATE ANY DATABASE, and broader permissions or roles.

Role-membership checks can be inconclusive for some group-based identities. Do not treat a role check alone as proof that the connection has (or lacks) every effective permission.

If the query indicates suitable permission but the original operation still fails, compare the execution identities again and inspect the exact failing statement. The error may come from another connection or an additional operation in a script.

Step 3: Have an Administrator Grant Only the Required Permission

  1. Decide whether this identity should actually create databases. An application’s everyday runtime account usually should not.
  2. If ongoing creation is appropriate, have an authorized administrator connect to the correct SQL Server instance.
  3. Have that administrator grant creation permission to the existing provisioning login:
USE [master];
GO
GRANT CREATE ANY DATABASE TO [DatabaseProvisioner];

The login must already exist. This command grants a permission; it does not create an account or assign a password.

CREATE ANY DATABASE is narrower than membership in dbcreator, which also permits operations on existing databases. It is still a significant permission: the login can create databases and normally becomes the owner of databases it creates.

Do not add an application login to sysadmin merely to clear this error. That grants control far beyond database provisioning.

If an explicit denial applies to the identity or one of its groups or roles, the administrator must resolve the intended permission policy. Adding another grant is not a reliable way to override a denial.

For a one-time deployment, the administrator can instead create the database, provision your deployment account inside it, and give you the target connection details. Connect to that existing database, deploy the approved schema, and verify that the application can open it.

Step 4: Create the Intended Database

  1. Return to the approved provisioning connection.
  2. Confirm that the intended database does not already exist, particularly if an earlier dialog reported a partial failure.
  3. Create it using its intended name:
USE [master];
GO
CREATE DATABASE [AppDatabase];
GO

This minimal statement uses the instance’s configured default database-file locations. It avoids introducing a copied file path from another computer or SQL Server installation.

For a production database, use the administrator-approved creation script if it specifies storage placement or other required settings.

Do not drop an existing database just to retry creation. If it already exists, determine whether the deployment should continue inside it.

Step 5: Verify the New Database and Finish Provisioning

  1. Query sys.databases for AppDatabase and inspect state_desc to confirm that the database exists and is online:
SELECT
    name,
    state_desc
FROM sys.databases
WHERE name = N'AppDatabase';
  1. Switch the provisioning connection to AppDatabase, then use DB_NAME() and USER_NAME() to confirm the database context and current database user:
USE [AppDatabase];
GO
SELECT
    DB_NAME() AS current_database,
    USER_NAME() AS current_database_user;
  1. Run the intended schema deployment under its authorized deployment identity.
  2. Connect with the application’s runtime identity and verify an operation the application actually needs.

Creation success does not prove that a separate runtime login has access. That account may still need a database user and appropriate application permissions.

If an administrator granted creation permission temporarily, the administrator can remove that direct grant after provisioning:

USE [master];
GO
REVOKE CREATE ANY DATABASE FROM [DatabaseProvisioner];

Fixing Applications, Hosted Databases, and Azure Connections

Correct the application target and use authorized provisioning and deployment identities for hosted databases, Azure SQL Database, or Azure SQL Managed Instance.

Applications and Automatic Database Creation

The account that creates a database does not have to be the account that runs the application.

An ORM, migration tool, or startup routine may attempt database creation when its configured target is missing. That behavior can make a connection-string mistake look like a permission problem.

To finish the repair:

  1. Check the application’s effective server, authentication identity, and target database.
  2. Correct a misspelled or overridden database name before granting anything.
  3. If the database genuinely needs provisioning, create it through an approved deployment identity or administrator.
  4. Apply the schema using the authorized deployment account.
  5. Start the application with its runtime account and test its normal database access.

If an application should use an existing database, its startup process should not depend on permission to create arbitrary databases.

Restricted Hosting and Existing Databases

Some hosting environments provide a database while deliberately withholding permission to create another one. In that situation, changing SSMS settings cannot supply a server permission the provider has not granted.

For a schema-only deployment:

  1. Connect directly to the assigned database.
  2. Review the generated script before executing it.
  3. Remove the database-creation portion and any database-file configuration intended for your local instance.
  4. Remove or correct database-context statements so the script targets the assigned database.
  5. Review explicit database-name references individually rather than performing a blind replacement.
  6. Run the schema deployment, inspect the resulting objects, and test the application connection.

Keep an unchanged copy of the original script. The deployment account still needs permission to create the required objects.

Do not execute application schema scripts in master.

Azure SQL Database and Managed Instance

Microsoft Azure SQL Managed Instance is an instance-level service, distinct from Azure SQL Database. Do not assume instructions for one service’s security model apply unchanged to the other.

For Azure SQL Managed Instance, check the actual login or Microsoft Entra identity and its effective instance permissions. If access comes through a group, verify the group’s authorization rather than assuming the individual must always have a separately listed login.

For Azure SQL Database, do not copy a SQL Server server-role repair without checking that it applies. A straightforward provisioning route is:

  1. Have the logical server’s SQL administrator or Microsoft Entra administrator create the database, or authorize an appropriate provisioning identity.
  2. Have the administrator provision the deployment and runtime identities in the target database.
  3. Open a new connection directly to that database.
  4. Deploy the schema and test the application’s normal connection.

Choose the target database when establishing the connection.

When the Database Exists or the Error Changes

A Database Appears Despite “Create Failed”

An SSMS dialog or deployment script can perform more than database creation. Creation may succeed while a later statement fails: for example, a database configuration change or an object-permission operation.

Do not immediately rerun the entire script.

Instead:

  1. Refresh the database list and verify whether the database exists.
  2. Capture the complete error details and the failing SQL statement.
  3. Inspect generated SQL or deployment logs to identify statements after database creation.
  4. Have the administrator correct the specific missing permission, or remove an unintended operation.
  5. Rerun only the appropriate remaining deployment work and test the result.

An error about executing a stored procedure is not proof that database creation failed. It concerns permission inside the database and needs its own targeted repair.

A File-Path or Operating-System Error Appears

A message about a missing directory, directory lookup, or operating-system access is a different problem from SQL authorization.

Database files are created on the SQL Server host, not necessarily on the computer running SSMS. File access also depends on the SQL Server service identity, not simply on your interactive Windows account.

To resolve that failure:

  1. Inspect the file paths in the creation script.
  2. Confirm that the directories exist on the database server.
  3. Have the server administrator verify the SQL Server service account’s required access.
  4. Correct the storage configuration or use approved instance defaults.
  5. Retry creation only after confirming the intended database does not already exist.
  6. Verify that the resulting database is online and accessible.

If a minimal creation statement succeeds but a script with explicit file locations fails, focus on the script’s storage configuration rather than adding broader SQL roles.

Confirm the Fix and Prevent a Repeat

A complete repair should pass these checks:

  • The connection reaches the intended SQL Server instance.
  • The identity used by the failing tool or application is known.
  • The intended database exists and is online.
  • Schema deployment completes under an authorized deployment identity.
  • The runtime account can perform its required operations.
  • Temporary creation grants have been removed where appropriate.

Keep provisioning separate from everyday application access. Record which account creates databases, which account deploys schema changes, and which account runs the application.

If the operation still fails, send the administrator the complete error, failing statement, server name, original login, execution login, and permission-check results. Redact passwords, tokens, and connection-string secrets before sharing logs.

Frequently Asked Questions

Why Am I Denied Permission When I Am a Windows Administrator?

Windows administrator membership does not automatically make your connection a SQL Server administrator. SQL Server authorizes the login and its SQL permissions, including permissions inherited through recognized Windows groups. Running SSMS as administrator normally does not fix a missing SQL grant; use an authorized SQL Server connection or have the administrator provision the required access.

Can I Create a Database on Localhost Without Permission?

No. Connecting to localhost changes where the server is located, not how SQL Server authorizes database creation. An existing SQL Server administrator must create the database for you or grant your login the required permission, even on a development computer.

How Do I Fix “CREATE FUNCTION Permission Denied in Database ‘master’”?

“CREATE FUNCTION permission denied in database ‘master’” means the function-creation attempt targeted master, not that database creation failed. If the function belongs to your application, connect the query window to the application database before executing the function script. Creating a function normally requires CREATE FUNCTION permission in that database and ALTER permission on its target schema; have an administrator authorize those operations if necessary.

How Do I Fix This Error During EPLAN Database Setup?

Check the SQL Server identity EPLAN actually uses for database setup, rather than assuming it uses your SSMS login. Have the SQL Server administrator authorize that setup identity for the required provisioning operation, then rerun setup and verify that EPLAN connects to the intended database. Keep any temporary setup privileges separate from the permissions needed for normal application use.