The %ls permission was denied on the object '%.*ls', database '%.*ls', schema '%.*ls'.

Error Message:
Msg 229, Level 14, State 5, Line 1
The %ls permission was denied on the object ‘%.*ls’, database ‘%.*ls’, schema ‘%.*ls’.

Severity level:
14.

Description:
This error message appears when you try to execute an operation on a database object, but you do not have the appropriate permission to execute this operation.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity level 14 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. Because of the missing permissions you cannot execute this operation. Contact your system administrator to discuss the permission issue.

Versions:
All versions of SQL Server.

Example(s):
USE Master;
GO
DROP LOGIN MyUser;
GO
CREATE LOGIN MyUser
  WITH PASSWORD = ‘abc’;
USE Northwind;
DROP USER MyUser;
CREATE USER MyUser FOR LOGIN MyUser
  WITH DEFAULT_SCHEMA = dbo;
GO
REVOKE SELECT ON OBJECT::dbo.Orders FROM MyUser;
GO
SETUSER ‘MyUser’
GO
SELECT *
  FROM dbo.Orders
SETUSER;

Remarks:
In the above example we first create a login and a user. The SELECT permission for the Orders table of the Northwind sample database is revoked from this user. Then we switch security context via the SETUSER command to the newly created user. The then executed SELECT statement against the Order table raises the error.

]]>

Leave a comment

Your email address will not be published.