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
Insert into create new table
提问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
回答by Wil P
If you have create rights you should be able to use an:
如果您有创建权限,您应该能够使用:
INSERT INTO MyTable SELECT
statement to do this.
INSERT INTO MyTable SELECT
声明来做到这一点。
EDIT:
编辑:
I had it wrong
我错了
SELECT * INTO MYNEWTABLE FROM MYSOURCETABLE