P
PsyberFox
Hi there,
I've got an SQL stored procedures which is working from SQL scheduled jobs -
so there are no syntax errors, etc. I am trying to run the sp from a form
control button within Access, but I get a syntax error on the
"case...datepart" command. This is the SQL sp:
insert into Prod_Knitting_Data_1 ([Date], [Month], [Year], MachNo,
MachModel, Shift, ShiftPeriod,
[Time], Style, [Size], Quantity, [8hrTarget], Target, Operator,
Technician, [TimeStamp])
select C.[Date], month([Date]), year([Date]), C.MachNo, KM.Model, C.Shift,
case when datepart(dw,C.[Date]) in (1,7) then 12 else 8 end as ShiftPeriod,
8 as [Time], C.Style, C.[Size], C.Quantity,
KP.Pairs as [8hrTarget],
case when Shift in ('E','F') then KP.Pairs / 8 * 12 else KP.Pairs / 8 * 8
end as Target,
KO.Operator, KT.Technician,
C.[TimeStamp]
from Prod_Knitting_Capture C left join
X03_Knit_Machines KM on KM.MachNo = C.MachNo left join
X03_Knit_MachinesProd KP on KP.Ref = substring(KM.Model,1,4) + C.Style left
join
X03_Knit_Operators KO on KO.[MachNo/Shift] = (C.MachNo + C.Shift) left join
--AND C.[Date] >= KO.StartDate left join
X03_Knit_Technicians KT on KT.MachNo = C.MachNo
Can someone please help...
Thank you!
I've got an SQL stored procedures which is working from SQL scheduled jobs -
so there are no syntax errors, etc. I am trying to run the sp from a form
control button within Access, but I get a syntax error on the
"case...datepart" command. This is the SQL sp:
insert into Prod_Knitting_Data_1 ([Date], [Month], [Year], MachNo,
MachModel, Shift, ShiftPeriod,
[Time], Style, [Size], Quantity, [8hrTarget], Target, Operator,
Technician, [TimeStamp])
select C.[Date], month([Date]), year([Date]), C.MachNo, KM.Model, C.Shift,
case when datepart(dw,C.[Date]) in (1,7) then 12 else 8 end as ShiftPeriod,
8 as [Time], C.Style, C.[Size], C.Quantity,
KP.Pairs as [8hrTarget],
case when Shift in ('E','F') then KP.Pairs / 8 * 12 else KP.Pairs / 8 * 8
end as Target,
KO.Operator, KT.Technician,
C.[TimeStamp]
from Prod_Knitting_Capture C left join
X03_Knit_Machines KM on KM.MachNo = C.MachNo left join
X03_Knit_MachinesProd KP on KP.Ref = substring(KM.Model,1,4) + C.Style left
join
X03_Knit_Operators KO on KO.[MachNo/Shift] = (C.MachNo + C.Shift) left join
--AND C.[Date] >= KO.StartDate left join
X03_Knit_Technicians KT on KT.MachNo = C.MachNo
Can someone please help...
Thank you!