I have a Master DB.
I want to make duplicate DB of the Master DB but not all tables just specified.
I have those table names in comma separated string.
tbl1, tbl2, tbl7, tbl10
etc.
I'm trying to make a stored procedure passing it new DB name
That creates the DB and replicate the given table to it. So far i have 2 thing, but i don't know how to loop through it. I'm new to DB so please guide how to achieve this.
(Note) I haven't found if an array can be used to loop through, the table names could also be stored in array variable, because the table names are hard coded.
The following is the sudo code i desire.
CREATE DATABASE %param_db%;
@tables = 'tbl1, tbl2, tbl7, tbl10';
loop through @tables as table_name
CREATE TABLE %param_db.table_name% LIKE Master.%table_name%;
End loop
Best Answer
Here are the steps to layout in the Stored Procedure
Here is that Stored Procedure