Is there something simple that I'm missing in the below insert statement (with a subquery)? Or am I way off?
I'm getting an error:
Incorrect syntax near ')'
which is on the last line
INSERT INTO insaudit (
insafindex,
insaiindex,
insadate,
insatime,
insacrop,
insafunction,
insaitem,
insatodata
)
SELECT dm_HRB_Legacy_Box_Conversion_hits.recindex,
f.recid,
convert(varchar(10), getdate(), 101),
convert(varchar(10), getdate(), 108),
'HRBConv' as insacrop,
'M' as insafunction,
3 as insaitem,
dm_HRB_Legacy_Box_Conversion_hits.new_curr_location
FROM dm_HRB_Legacy_Box_Conversion_hits
INNER JOIN dm_HRB_Legacy_Box_Conversion
ON dm_HRB_Legacy_Box_Conversion_hits.HRB_recid = dm_HRB_Legacy_Box_Conversion.recid
INNER JOIN
(
Select
f.recid
from dm_HRB_Legacy_Box_Conversion_hits f
INNER JOIN dm_HRB_Legacy_Box_Conversion
ON f.HRB_recid = dm_HRB_Legacy_Box_Conversion.recid
WHERE (f.type = 'I')
AND (dm_HRB_Legacy_Box_Conversion.process_number = '1'))
I'm getting an error:
Incorrect syntax near ')'
which is on the last line
INSERT INTO insaudit (
insafindex,
insaiindex,
insadate,
insatime,
insacrop,
insafunction,
insaitem,
insatodata
)
SELECT dm_HRB_Legacy_Box_Conversion_hits.recindex,
f.recid,
convert(varchar(10), getdate(), 101),
convert(varchar(10), getdate(), 108),
'HRBConv' as insacrop,
'M' as insafunction,
3 as insaitem,
dm_HRB_Legacy_Box_Conversion_hits.new_curr_location
FROM dm_HRB_Legacy_Box_Conversion_hits
INNER JOIN dm_HRB_Legacy_Box_Conversion
ON dm_HRB_Legacy_Box_Conversion_hits.HRB_recid = dm_HRB_Legacy_Box_Conversion.recid
INNER JOIN
(
Select
f.recid
from dm_HRB_Legacy_Box_Conversion_hits f
INNER JOIN dm_HRB_Legacy_Box_Conversion
ON f.HRB_recid = dm_HRB_Legacy_Box_Conversion.recid
WHERE (f.type = 'I')
AND (dm_HRB_Legacy_Box_Conversion.process_number = '1'))