Home > database >  I want to create A new table, but this is A table column name is my query table B of the result set,
I want to create A new table, but this is A table column name is my query table B of the result set,

Time:09-21

I want to create A new table, but this is A table column name is my query table B of the result set, can you tell me how to achieve? A stored procedure?

CodePudding user response:

Don't need a stored procedure, a single SQL can solve,
 
The create table as the select B table field list from B;

CodePudding user response:

To use dynamic SQL to do,

CodePudding user response:

Agree with upstairs, only through a dynamic SQL

If it is a one-off operation, can be directly generated string, manual operation

CodePudding user response:

The second floor of the SQL is not to go, want a stored procedure stem

CodePudding user response:

 
- copy table structure and data
The create table as the select B table field list from B;
- only copy table structure
The create table as the select B table field list from B list table fields where B=1;

CodePudding user response:

The Create table as select table columns field from B B where 1=0
  • Related