Insert into create new table

2020-06-09 04:18发布

问题:

I have two large tables and want to combine all of the column names (not as a view) into a new table.

I do not have permission to right click on each table and choose CREATE TO SCRIPT, so I was wondering if there is a way to INSERT both Tables into a new table without specifying the column data types?

回答1:

SELECT top 0 *
INTO NewTable
FROM BigTable1
    CROSS JOIN BigTable2


回答2:

For T-SQL,

SELECT ...
INTO MyTable
FROM ...


回答3:

You can use a SELECT INTO TSQL query - see MSDN link.



回答4:

If you have create rights you should be able to use an:

INSERT INTO MyTable SELECT statement to do this.

EDIT:

I had it wrong

SELECT * INTO MYNEWTABLE FROM MYSOURCETABLE