First when a saw this line, I was glad to see a trick how to work around the limitiation, that the Sqlserver does not allow to change the database context within a stored proc. But playing around with it quickly revealed that this workaround does not work around.
Statements called within an exec('...') clause are executed as a batch separate from the caller's batch, including the database context.
-- start example
exec('use master; print db_name();');
-- end example
The output will be: