Fix “The specified schema name either does not exist or you do not have permission to use it” in SQL Server

There are a couple of obvious reasons you might be seeing an error that reads something like “The specified schema name “XYZ” either does not exist or you do not have permission to use it” in SQL Server. This typically happens when creating an object on a schema that doesn’t exist or you don’t have permissions.

This article shows an example of the error and a couple of ways to fix it, depending on the underlying cause.

What Triggers Msg 2760?

SQL Server throws error Msg 2760 when it can’t locate the schema referenced in a statement. This usually happens for one of two reasons:

  1. The schema simply doesn’t exist in the database.
  2. The user executing the statement lacks permission to see or use that schema.

Below is a quick example that reproduces the error, followed by two options for resolving it.

Example of Error

Here’s an example of code that produces the error:

CREATE TABLE Sales.Products (
    ProductID      INT PRIMARY KEY,
    ProductName    NVARCHAR(100) NOT NULL,
    Category       NVARCHAR(50)  NOT NULL
);

Output:

Msg 2760, Level 16, State 1, Line 1
The specified schema name "Sales" either does not exist or you do not have permission to use it.

As the error message suggests, the schema either doesn’t exist or I don’t have permission to use it.

Solution 1 – Create the Missing Schema

If the schema truly doesn’t exist, you need to create it before referencing objects within it:

CREATE SCHEMA sales AUTHORIZATION dbo;

Now we can go ahead and create the table:

CREATE TABLE Sales.Products (
    ProductID      INT PRIMARY KEY,
    ProductName    NVARCHAR(100) NOT NULL,
    Category       NVARCHAR(50)  NOT NULL
);

Output:

Commands completed successfully.

You can optionally specify an owner (e.g., AUTHORIZATION dbo) like we did here to control who can manage objects inside the schema.

Solution 2 – Grant the Required Permissions

Sometimes the schema already exists, but the current login can’t see it. In that case, grant the necessary rights.

-- Ensure we're on the correct database
USE demo;

-- Verify the schema exists (run as a privileged user)
SELECT name FROM sys.schemas WHERE name = 'sales';

-- Allow user to create tables in the database
GRANT CREATE TABLE TO TestUser;

-- Allow user to alter the schema (needed to create objects inside it)
GRANT ALTER ON SCHEMA::sales TO TestUser;

Replace demo with your database name, sales with the schema, and TestUser with the actual user, and be sure to specify the actual permissions that you want that user to have.