how to run SQL query without permission
You will need cross-database permissions.
The most secure solution is to create a dedicated user from Certificate in the &quot;example1&quot; DB and grant this user read privileges. Then in the &quot;example2&quot; DB you will sign this stored procedure with the same certificate, so the procedure will be able to use permissions of the previously created user.
You can find detailed tutorial here. And for a longer elaboration on the topic, check out Erland's classic article.
Another option would be to enable 'Cross-database ownership chaining', but it is not recommended because of security implications.