本文介绍了是否可以将 SELECT INTO 子句与 UNION [ALL] 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 SQL Server 中,这将从客户表中插入 100 条记录到 tmpFerdeen :-
In SQL Server this inserts 100 records, from the Customers table into tmpFerdeen :-
SELECT top(100)*
INTO tmpFerdeen
FROM Customers
是否可以跨 UNION ALL SELECT 执行 SELECT INTO :-
Is it possible to do a SELECT INTO across a UNION ALL SELECT :-
SELECT top(100)*
FROM Customers
UNION All
SELECT top(100)*
FROM CustomerEurope
UNION All
SELECT top(100)*
FROM CustomerAsia
UNION All
SELECT top(100)*
FROM CustomerAmericas
不太确定在哪里添加 INTO 子句.
Not too sure where to add the INTO clause.
推荐答案
这适用于 SQL Server:
This works in SQL Server:
SELECT * INTO tmpFerdeen FROM (
SELECT top 100 *
FROM Customers
UNION All
SELECT top 100 *
FROM CustomerEurope
UNION All
SELECT top 100 *
FROM CustomerAsia
UNION All
SELECT top 100 *
FROM CustomerAmericas
) as tmp
这篇关于是否可以将 SELECT INTO 子句与 UNION [ALL] 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!