When a job executes on a SQL Server server, the following error message is encountered:
Message:
Executed as user:dbo. The server principal "SA" is not able to access the database "XXXX" under the current security context. [SQLSTATE 08004] (Error 916). The step failed.
The stored procedure executed by the job itself is very simple, that is, after the history data in database A is processed and archived into the A_history library, the result is a problem. Removing the job's stored procedure from the SSMS client executes successfully, no problem, but the job execution encounters this from me. After tossing a bit, finally understand the story. Originally, the "Advanced" option for this job step is set to run as user as dbo.
To cancel this option, the problem can be resolved. This option is never set when a job is set by a person, but there are some developer-created jobs that have the option set here, which results in a problem.
Other than that. I this blog SQL Agent Job Report "Access to the remote server is denied because the current security context was not trusted" inside is actually this Problem. Ridiculous at the time although solved, yincuoyangcha solved the problem, but still did not find root cause. This is the ring!
The server principal "SA" is not able to access the database "XXXX" under the current security context