SQL 插入创建新表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8314435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:27:42  来源:igfitidea点击:

Insert into create new table

sqldatabasetsqlinsert

提问by tdjfdjdj

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 permissionto 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?

没有权限来右击每个表并选择创建脚本,所以我不知道是否有一种方法可以同时插入表到一个新表时没有指定列的数据类型?

回答by Peter Majeed

SELECT top 0 *
INTO NewTable
FROM BigTable1
    CROSS JOIN BigTable2

回答by Bert

For T-SQL,

对于 T-SQL,

SELECT ...
INTO MyTable
FROM ...

回答by Barry Kaye

You can use a SELECT INTOTSQL query - see MSDN link.

您可以使用SELECT INTOTSQL 查询 - 请参阅MSDN 链接

回答by Wil P

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

如果您有创建权限,您应该能够使用:

INSERT INTO MyTable SELECTstatement to do this.

INSERT INTO MyTable SELECT声明来做到这一点。

EDIT:

编辑:

I had it wrong

我错了

SELECT * INTO MYNEWTABLE FROM MYSOURCETABLE