I have a stored procedure that I can execute in SSMS with a non domain SQL Server user.
This stored procedure selects data from tables in one database (DB1) truncates and selects into a table in DB2.
The user has datareader,datawriter and dbowner for both databases.
Problem:
When I execute the stored procedure via SS Agent with execute as the user I get the following error
The server principal [user] is not able to access the database [DB1] under the current security context.
Actions taken So far:
I have tried to resolve this so far by:
- Turning on db chaining for both databases
- Deleted the user from DB1 and added again
- Checked using
EXEC sp_change_users_login @Action=’Report’
to see if user orphaned. As this is a database that is a restore of a live one. However I added the user after the restore. The user was not listed as orphaned