// SQL Server error reference

SQL Server error 262: Permission denied in database

You tried a statement that needs a database-level permission you don't have, such as CREATE TABLE, CREATE PROCEDURE or SHOWPLAN.

Error number
262
Severity
16
Category
Permissions
Error message
%ls permission denied in database '%.*ls'.

What it means

Some statements are not about one object but need a permission on the database itself: CREATE TABLE, CREATE VIEW, CREATE PROCEDURE, SHOWPLAN and so on. Error 262 names the permission (for example CREATE TABLE permission denied in database 'SalesDb').

Common causes

  • The user can read and write data but was never granted DDL permissions.
  • Viewing an execution plan without SHOWPLAN permission.
  • Creating an object in a schema you don't own and have no ALTER permission on (CREATE TABLE also needs ALTER on the schema).

How to fix it

  1. Grant the database permission and, for creating objects, ALTER on the target schema.

    GRANT CREATE TABLE TO app_user;
    GRANT ALTER ON SCHEMA::dbo TO app_user;
  2. For execution plans, grant SHOWPLAN.

    GRANT SHOWPLAN TO app_user;
  3. For a developer who needs full DDL rights in a dev database, add them to db_ddladmin.

    ALTER ROLE db_ddladmin ADD MEMBER dev_user;

Related errors

More permissions errors

The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.

// fewer errors, faster fixes

Work on SQL Server in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.