Create multiple tables using select statement

Database
Enthusiast

Create multiple tables using select statement

Hello everyone

I am new to this community.

Ok, So what i want to do is that i want to create multiple table using select statement from multiple tables. Something like this:

Create table &variable1 as ( select * from &variable2) with no data;

I want to pass multiple variables inside this to create table.

something like a procedure may be.

Thanks in advance

2 REPLIES
Supporter

Re: Create multiple tables using select statement

you can write a stored procedure with dynamic sql - if you have the right to use dynamic sql.

Alternative approach is to use SQL to generate the statement based on a small reference table which contains target tablename and source tablename and execute the generated SQLs afterwards.

Enthusiast

Re: Create multiple tables using select statement

Thanks for the kind feedback Ulrich
That's what I had in mind.
To create a reference table and call the table name inside a procedure.
But that's what I want to ask.
How to do that? How to make a procedure in which I pass the source table and target table name.
Kindly help.