Msg 229, Level 14, State 5, Line 1
The %ls permission was denied on the object ‘%.*ls’, database ‘%.*ls’, schema ‘%.*ls’.
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.
The T-SQL statement can be parsed, but causes the error at runtime.
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.
All versions of SQL Server.
DROP LOGIN MyUser;
CREATE LOGIN MyUser
WITH PASSWORD = ‘abc’;
DROP USER MyUser;
CREATE USER MyUser FOR LOGIN MyUser
WITH DEFAULT_SCHEMA = dbo;
REVOKE SELECT ON OBJECT::dbo.Orders FROM MyUser;
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.