Msg 15517 Execute as User.
Applies to: SQL Server 2019 Developer Edition.
Date created: August 16, 2020.
If you are connected to a SQL Server instance with a specific login and you
try to execute a T-SQL statement as another login, you may find the following
Msg 15517, Level 16, State 1, Line 1
Cannot execute as the database principal because the principal "alberto" does
not exist, this type of principal cannot be impersonated, or you do not have
Msg 229, Level 14, State 5, Line 3
The SELECT permission was denied on the object 'tblCheques', database 'CuentasXPagar',
The "morillo" login does not have "impersonate" permission on the principal "alberto".
To resolve this error, provide "impersonate" permission to the first
login ("morillo") on the second principal ("alberto").
After that the first login will be able to impersonate the principal and execute
the statement as the principal.