Skip to content
Microsoft SQL Server

SQL Server Error 229

The permission was denied on the object

Severity 14 Logins & Permissions
Applies to: All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last technically reviewed 23 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Msg 229, Level 14, State 5, Line 1
The SELECT permission was denied on the object 'Salaries', database 'HR', schema 'dbo'.
Other forms of this message
Other permissions use the same template
The EXECUTE permission was denied on the object 'GetSalaryReport', database 'HR', schema 'dbo'.
The UPDATE permission was denied on the object 'Salaries', database 'HR', schema 'dbo'.
Raised inside a stored procedure (the header names the procedure)
Msg 229, Level 14, State 5, Procedure dbo.GetSalaryReport, Line 3
The SELECT permission was denied on the object 'Salaries', database 'HR', schema 'hr'.
Error number
229
Severity
14 (user-correctable error)
State
5
Product
Microsoft SQL Server Database Engine
Versions
All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last reviewed
23 October 2026

What it means

Error 229 means the current user can connect to the database but lacks one specific permission (such as SELECT, UPDATE or EXECUTE) on the table, view or procedure named in the message.

Read the message as four facts: the permission that was checked (SELECT), the object (Salaries), the database (HR) and the schema (dbo). The statement stopped at that check; nothing was read or changed. Severity 14 marks a security error that an administrator can fix by changing permissions, and the batch carries on with the next statement.

The user either has no GRANT for that action (directly, through a role, or on the whole schema), or something it belongs to carries a DENY, which always wins over a GRANT. When the header names a procedure, the check failed inside the procedure body: the caller was allowed to run the procedure, but the ownership chain to the table was broken. A missing right to create objects is error 262 instead.

Common causes

  • A new user or application login was given access to the database (CONNECT) but never granted rights on the objects it uses.
  • A DENY on the object or schema, often on a role the user belongs to, overrides a GRANT such as membership of db_datareader.
  • A stored procedure reads a table that has a different owner (for example a table in a schema owned by another user), so ownership chaining does not apply and the permissions of the caller are checked.
  • Dynamic SQL inside a procedure (EXEC or sp_executesql) is checked against the permissions of the caller, so ownership chaining does not cover it.
  • The application connects as a different user than you tested with, for example a Windows group login instead of your own.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

See every GRANT and DENY on the object

Run in the database named in the message. Includes permissions granted on the whole schema.

SELECT pr.name AS principal, pr.type_desc, pe.class_desc,
       pe.permission_name, pe.state_desc
FROM sys.database_permissions AS pe
JOIN sys.database_principals AS pr ON pr.principal_id = pe.grantee_principal_id
WHERE (pe.class = 1 AND pe.major_id = OBJECT_ID(N'dbo.Salaries'))
   OR (pe.class = 3 AND pe.major_id = SCHEMA_ID(N'dbo'))
ORDER BY pr.name, pe.permission_name;
What to look for

A DENY row for the user or for any role it belongs to explains the error even when a GRANT exists. No row for the user, its roles or public means nothing was granted.

List the roles the user belongs to

SELECT r.name AS role_name, m.name AS member_name
FROM sys.database_role_members AS rm
JOIN sys.database_principals AS r ON r.principal_id = rm.role_principal_id
JOIN sys.database_principals AS m ON m.principal_id = rm.member_principal_id
WHERE m.name = N'ReportUser';
What to look for

Compare these roles with the DENY rows from the first query. Membership of db_denydatareader or db_denydatawriter also blocks reads or writes on every table.

Ask SQL Server what your own connection may do

Run this while connected as the affected user (or the application account).

SELECT HAS_PERMS_BY_NAME(N'dbo.Salaries', N'OBJECT', N'SELECT') AS can_select,
       HAS_PERMS_BY_NAME(N'dbo.Salaries', N'OBJECT', N'UPDATE') AS can_update;

SELECT permission_name
FROM sys.fn_my_permissions(N'dbo.Salaries', N'OBJECT');
What to look for

0 confirms the permission is missing for this connection; the second query lists what it does have on the object.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Grant the permission named in the message, to a role

Changes permissions

Grant exactly the permission the message names, on exactly that object. Granting to a role and adding users to it keeps permissions easy to review.

CREATE ROLE PayrollReaders;
GRANT SELECT ON dbo.Salaries TO PayrollReaders;
ALTER ROLE PayrollReaders ADD MEMBER [ReportUser];

Grant on the schema when the user needs every object in it

Changes permissions

A schema-level grant covers existing and future objects in that schema, without the database-wide reach of db_datareader.

GRANT SELECT ON SCHEMA::dbo TO PayrollReaders;

Remove a DENY that overrides the grant

Changes permissions

If the first diagnostic shows a DENY, remove it with REVOKE (which deletes the DENY row) on the principal that holds it. Check first why it was added: a DENY is often deliberate, for example to keep salary data away from a reporting role.

REVOKE SELECT ON dbo.Salaries FROM NoPayroll;

Let a procedure read through ownership chaining

Changes schema

When the error is raised inside a procedure, make the procedure and the tables it reads share an owner (for example both in dbo), then grant only EXECUTE on the procedure. Callers never need rights on the tables. Moving a table between schemas changes its name for every query, so plan it with the application owners.

ALTER SCHEMA dbo TRANSFER hr.Salaries;
GRANT EXECUTE ON dbo.GetSalaryReport TO [AppUser];

Examples

SELECT denied on a table

CREATE TABLE dbo.Salaries (id INT PRIMARY KEY, amount DECIMAL(10,2));
CREATE USER AppUser WITHOUT LOGIN;   -- a user with CONNECT only

EXECUTE AS USER = 'AppUser';
SELECT id, amount FROM dbo.Salaries;
REVERT;
Result
Msg 229, Level 14, State 5, Line 5
The SELECT permission was denied on the object 'Salaries', database 'HR', schema 'dbo'.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

A DENY on a role beats db_datareader

CREATE TABLE dbo.Salaries (id INT PRIMARY KEY, amount DECIMAL(10,2));
CREATE USER ReportUser WITHOUT LOGIN;
ALTER ROLE db_datareader ADD MEMBER ReportUser;
CREATE ROLE NoPayroll;
ALTER ROLE NoPayroll ADD MEMBER ReportUser;
DENY SELECT ON dbo.Salaries TO NoPayroll;

EXECUTE AS USER = 'ReportUser';
SELECT id, amount FROM dbo.Salaries;   -- db_datareader is not enough
REVERT;
Result
Msg 229, Level 14, State 5, Line 9
The SELECT permission was denied on the object 'Salaries', database 'HR', schema 'dbo'.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

A broken ownership chain inside a procedure

CREATE USER HrOwner WITHOUT LOGIN;
GO
CREATE SCHEMA hr AUTHORIZATION HrOwner;   -- hr is not owned by dbo
GO
CREATE TABLE hr.Salaries (id INT PRIMARY KEY, amount DECIMAL(10,2));
GO
CREATE PROCEDURE dbo.GetSalaryReport
AS
    SELECT id, amount FROM hr.Salaries;
GO
CREATE USER AppUser WITHOUT LOGIN;
GRANT EXECUTE ON dbo.GetSalaryReport TO AppUser;

EXECUTE AS USER = 'AppUser';
EXEC dbo.GetSalaryReport;   -- allowed to run it, not to read hr.Salaries
REVERT;
Result
Msg 229, Level 14, State 5, Procedure dbo.GetSalaryReport, Line 3
The SELECT permission was denied on the object 'Salaries', database 'HR', schema 'hr'.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

How to prevent it

Design permissions around roles: one role per job (reporting, the application, deployments), with grants on schemas or objects, and users added to roles. Keep business tables and the procedures that use them under one owner so callers need only EXECUTE.

Use DENY sparingly and document each one, because it silently overrides every grant. Test new features while connected as the application account, not as an administrator, so 229 shows up in testing. See the SQL Server security lesson for the full model.

Common questions

Why do I get error 229 when the user is in db_datareader?

A DENY on the object, on its schema, or on any role the user belongs to (including db_denydatareader) overrides the grant that db_datareader gives. List the DENY rows with the first diagnostic query.

What is the difference between error 229 and error 262?

Error 229 is about using an object that already exists (SELECT, INSERT, UPDATE, DELETE, EXECUTE). Error 262 is about creating objects (CREATE TABLE, CREATE PROCEDURE) in the database.

Why does a stored procedure raise 229 on a table the caller cannot see?

Ownership chaining skips the table check only when the procedure and table have the same owner and the access is not dynamic SQL. If the owners differ, SQL Server checks the permissions of the caller on the table.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.