Trying to insert values into a temporary table using SQL Server 2008, getting:
Msg 116, Level 16, State 1, Procedure Test_temp_table, Line 274
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
With this query:
VALUES(
(select
a.*, b.[formal name], c.*, d.*
from
selecthr20.employee.[career history] a,
selecthr20.Employee.[Current Appointments As At Evaluation Date] b,
Employee.[BSK Changes in Selected Period] c,
selecthr20.employee.[career history extra detail] d
where
a.[appointment number] = b.[appointment number]
and a.[career number] = c.[primary key number]
and a.[career number] = d.[career number]
and c.[primary key number] = d.[career number]
and c.[primary key name] = 'Career Number'
and b.[person number] in (select b.[person number]
from employee.[current pay as at evaluation date]
where substring([Payroll Name],1,6) = 'DOV020')))
INSERT INTO ... SELECTdoesn't use theVALUES ()expression at all. It's justINSERT INTO #TempTable SELECT .....JOINsyntax in the ANSI-92 SQL Standard (more than 20 years ago) and its use is discouraged