Create a new table from two existing table

Allen_Delon

Hello,

I need your help. I am trying to create a new table using two existing table (TABLE1 and TABLE2). I have no idea what SQL Server technique I can use to resolve this issue.

SELECT A AS A1, B AS B1, C AS C1 FROM TABLE1
Result:
        A1  B1  C1
        3   4   1
        1   2   0

SELECT E2 AS A1, F2 AS B1, G2 AS C1 FROM TABLE2
Result:
        A1  B1  C1
        4   7   1
        2   8   6

Let’s name the new table 'My_Table' which includes all data from TABLE1 and TABLE2.

SELECT * FROM My_Table
Result:
        A1  B1  C1
        3   4   1
        1   2   0
        4   7   1
        2   8   6

I want to save this table in my database and use it in the future.

Any help would be appreciated.

robdjc

You can try to use the INTO clause and a UNION of both selects.

SELECT A AS A1, B AS B1, C AS C1 
INTO My_Table
FROM TABLE1
UNION
SELECT E2 AS A1, F2 AS B1, G2 AS C1 
FROM TABLE2

Note, that a UNION will also remove duplicate records. If that is not expected, then check out UNION ALL.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Create empty SQL table from existing table in Azure

From Dev

Adding new data from JSON to existing table

From Dev

Papyrus - Create a Table from an existing configuration

From Dev

Create new hive table from existing external portioned table

From Dev

How to create new field in view with some offset (field of table) from existing field (another field of table)?

From Dev

How to create a new table from existing table with both keys and data in SQL Server 2012 (Management Studio)?

From Dev

Create a new table based on existing table

From Dev

Creating a new table in database with description from existing table as an input

From Dev

Create a new table from two existing table

From Dev

T-SQL Add new column in existing table and fill with value from two another existing column

From Dev

Create a new aggregate collection from two existing collections?

From Dev

SQL - INSERT new row by using sum of two existing rows from same table

From Dev

Create a new table (copy of an existing) with date order

From Dev

Word 2013 - How to create a new table style from an existing table style?

From Dev

Create table from two rows, one column

From Dev

Create empty SQL table from existing table in Azure

From Dev

Cassandra - Import from CSV and create new table?

From Dev

Create table joining two existing tables in Shark Hive

From Dev

Create an HTML table from an existing array

From Dev

Create new hive table from existing external portioned table

From Dev

Need to create a new table from existing table

From Dev

Create New MySQL table with structure of existing table

From Dev

laravel - Create a new migration table with data from existing

From Dev

How to create table from existing 2 table with default value in oracle

From Dev

SQL: Create new table from old

From Dev

Create new table from old table and add 2 new columns

From Dev

create a new hive table with values from two hive tables

From Dev

insert into new table from existing table with an added new field

From Dev

Is it possible to create a new table from an unpivot results?

Related Related

  1. 1

    Create empty SQL table from existing table in Azure

  2. 2

    Adding new data from JSON to existing table

  3. 3

    Papyrus - Create a Table from an existing configuration

  4. 4

    Create new hive table from existing external portioned table

  5. 5

    How to create new field in view with some offset (field of table) from existing field (another field of table)?

  6. 6

    How to create a new table from existing table with both keys and data in SQL Server 2012 (Management Studio)?

  7. 7

    Create a new table based on existing table

  8. 8

    Creating a new table in database with description from existing table as an input

  9. 9

    Create a new table from two existing table

  10. 10

    T-SQL Add new column in existing table and fill with value from two another existing column

  11. 11

    Create a new aggregate collection from two existing collections?

  12. 12

    SQL - INSERT new row by using sum of two existing rows from same table

  13. 13

    Create a new table (copy of an existing) with date order

  14. 14

    Word 2013 - How to create a new table style from an existing table style?

  15. 15

    Create table from two rows, one column

  16. 16

    Create empty SQL table from existing table in Azure

  17. 17

    Cassandra - Import from CSV and create new table?

  18. 18

    Create table joining two existing tables in Shark Hive

  19. 19

    Create an HTML table from an existing array

  20. 20

    Create new hive table from existing external portioned table

  21. 21

    Need to create a new table from existing table

  22. 22

    Create New MySQL table with structure of existing table

  23. 23

    laravel - Create a new migration table with data from existing

  24. 24

    How to create table from existing 2 table with default value in oracle

  25. 25

    SQL: Create new table from old

  26. 26

    Create new table from old table and add 2 new columns

  27. 27

    create a new hive table with values from two hive tables

  28. 28

    insert into new table from existing table with an added new field

  29. 29

    Is it possible to create a new table from an unpivot results?

HotTag

Archive