SQL中的语法错误

时间:2009-07-18 03:49:35

标签: sql

SELECT *
INTO Temp3

from

( SELECT B.Name
FROM [Temp2] as B 
WHERE B.Name
Not IN (
SELECT E.WorkerName
FROM WorkerDetail as E ) )

为什么会产生错误?

2 个答案:

答案 0 :(得分:2)

如果要使用派生表,则需要使用别名:

SELECT T1.*
INTO Temp3

from

( SELECT B.Name
FROM [Temp2] as B 
WHERE B.Name
Not IN (
SELECT E.WorkerName
FROM WorkerDetail as E ) )  AS T1

但是,我不确定您是否确实需要使用派生表。

这也应该有效:

SELECT B.Name
INTO Temp3
FROM [Temp2] as B 
WHERE B.Name
Not IN (
SELECT E.WorkerName
FROM WorkerDetail as E ) 

答案 1 :(得分:1)

也许Temp3已经存在? 在MSSQL SELECT..INTO中用于用数据填充新表。 如果存在此表,则可以使用INSERT INTO .. SELECT FROM语句。