SELECT *
INTO Temp3
from
( SELECT B.Name
FROM [Temp2] as B
WHERE B.Name
Not IN (
SELECT E.WorkerName
FROM WorkerDetail as E ) )
Why does this produce an error?
SELECT *
INTO Temp3
from
( SELECT B.Name
FROM [Temp2] as B
WHERE B.Name
Not IN (
SELECT E.WorkerName
FROM WorkerDetail as E ) )
Why does this produce an error?
Maybe Temp3 already exists? In MSSQL SELECT..INTO used to populate new table with data. If this table exist, you can use INSERT INTO .. SELECT FROM statement.
If you want to use a derived table you need to alias it:
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
I'm not sure if you actually need to use a derived table, however.
This should also work:
SELECT B.Name
INTO Temp3
FROM [Temp2] as B
WHERE B.Name
Not IN (
SELECT E.WorkerName
FROM WorkerDetail as E )