Here is an example for how your SQL should look like inside the Advanced Query
/* %LogicalDatabase%=GetLogicalDatabase({Customer}) */
EXEC [dbo].[CustomerGetByCustomerID] @CustomerID
Use Logical Database to tell the platform what database connection to use to execute the stored procedure. In this case the connection for the Customer entity will be used. This entity is defined in an Extension. So the user id from the Extension will be used to execute the stored procedure.
If you don't put any hint OutSystemsUpdate will be used so you would have to grant OutSystemsUpdate execute permissions to your SP. In this case you most likely also have to add the db name to the call
e.g. CustomersDB.dbo.CustomerGetByCustomerID