All Forums Database
hercules 5 posts Joined 12/14
03 Dec 2014
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

ulrich 816 posts Joined 09/09
04 Dec 2014

 
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.

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

hercules 5 posts Joined 12/14
04 Dec 2014

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.

You must sign in to leave a comment.