sql – 是否可以使用带有UNION [ALL]的SELECT INTO子句?

在SQL Server中,将从Customers表中插入100条记录到tmpFerdeen中: –

SELECT top(100)*
INTO tmpFerdeen
FROM Customers

是否可以在UNION ALL SELECT中执行SELECT INTO: –

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子句。

这在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
http://stackoverflow.com/questions/591382/is-it-possible-to-use-the-select-into-clause-with-union-all

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:sql – 是否可以使用带有UNION [ALL]的SELECT INTO子句?