SQL Server error 15151: Object doesn't exist or no permission
A security statement such as ALTER LOGIN, DROP USER or GRANT named a principal or object that doesn't exist, or that you aren't allowed to see.
- Error number
15151- Severity
- 16
- Category
- Permissions
What it means
SQL Server raises 15151 from statements that manage security (ALTER LOGIN, DROP USER, ALTER ROLE, GRANT ... TO) when the target can't be found. Like 3701, it doesn't tell you which: the name may be wrong, it may live in another database or on the server instead of the database, or you may lack permission to see it.
Common causes
- A typo in the login, user or role name.
- Mixing up a server login and a database user:
ALTER LOGINworks on server logins,ALTER USERon users in the current database. - Running in the wrong database, so the user or role isn't there.
- Missing permission such as
ALTER ANY LOGINorALTER ANY USER, which makes the principal invisible to you.
How to fix it
-
Check that the server login exists.
SELECT name, type_desc FROM sys.server_principals WHERE name = N'app_user';
-
Check the database user or role in the database you're in.
SELECT DB_NAME() AS current_db, name, type_desc FROM sys.database_principals WHERE name = N'app_user';
-
Run the statement in the right database (
USE SalesDb;), or as a principal with the needed permission.
Related errors
15023User, group, or role already exists3701Cannot drop, object not found18456Login failed for user
More permissions errors
916Login can't access the database229Permission denied on object262Permission denied in database15025The server principal already exists15138User owns a schema, cannot be dropped
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.
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.