I would like to dynamically use a database inside a stored procedure but the
use database_name command is not supported inside procedures.
What alternatives are there?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
From MySQL Documentation on Stored Routine Syntax When the routine is invoked, an implicit USE db_name is performed (and undone when the routine terminates). USE statements within stored routines are not permitted
If you need to query tables from other databases you can do it like DBName.TableName. and you can change DBName dynamically.