Hi, Elgin,
I'm not positive on this- but I don't believe you can use dynamic SQL simply for a line of code that changes the database (using a USE).
The reason is that dynamic SQL returns to the previous context before it executed.
To the best of my awareness, you'd need to string together some statements with a semicolon...
i.e. USE MyDatabase ; select * from sometable where 1=0 , ETC.
Again, I'm not certain on this, but I didn't think you could execute a single line of dynamic SQL just to change database context.