>>It doesn't work either because USE command is scoped to a batch.
>
>Could you elaborate more on the topic? When I do that, it works.
It reverts back to the current DB after EXECUTE (which is a separate batch) completes.
SELECT DB_NAME()
EXECUTE(@Command + ';SELECT DB_NAME()')
SELECT DB_NAME()
--sb--