October 7, 2015 at 7:37 am
INSERT INTO Lookup
(
LookupTypeID,
LookupReference,
Description,
OtherReference,
CompanyIDs,
EffectiveFromDate
)
;with cte
as
(
select distinct NHF.UOM,MAP.DESCRIPTION
from Dataload..RepairSORNHF NHF
INNER JOIN
Dataload..RepairSORMapping MAP
ONNHF.UOM = MAP.CODE
)
select 40 as LookupTypeId,
ROW_NUMBER() over (order by (select 0))+(select max(LookupReference) from Lookup where LookupTypeId=40) as LookupReference,
DESCRIPTION as Description,
UOM as OtherReference,
'1' as CompanyIDs,
convert(date,Getdate()) as EffectiveFromDate
from cte
Gives me an error of -
Msg 102, Level 15, State 1, Line 13
Incorrect syntax near ';'.
October 7, 2015 at 7:42 am
Put the INSERT statement below the CTE.
October 7, 2015 at 7:42 am
The CTE must come first, before the INSERT keyword.
The semicolon you had in there had terminated your statement before it had begun.
with cte
as
(
select distinct NHF.UOM,MAP.DESCRIPTION
from Dataload..RepairSORNHF NHF
INNER JOIN
Dataload..RepairSORMapping MAP
ONNHF.UOM = MAP.CODE
)
INSERT INTO Lookup
(
LookupTypeID,
LookupReference,
Description,
OtherReference,
CompanyIDs,
EffectiveFromDate
)
select 40 as LookupTypeId,
ROW_NUMBER() over (order by (select 0))+(select max(LookupReference) from Lookup where LookupTypeId=40) as LookupReference,
DESCRIPTION as Description,
UOM as OtherReference,
'1' as CompanyIDs,
convert(date,Getdate()) as EffectiveFromDate
from cte
October 7, 2015 at 7:44 am
What a numpty.
Thanks
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply