在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
您根本不需要派生表.
刚刚放在第一个INTO
之后SELECT
SELECT top(100)* INTO tmpFerdeen FROM Customers UNION All SELECT top(100)* FROM CustomerEurope UNION All SELECT top(100)* FROM CustomerAsia UNION All SELECT top(100)* FROM CustomerAmericas
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 Blablabal
这种"Blablabal"是必要的