That’s still pretty horrid … must be some way to code that out to make it SARGable?
Could have a computed column I suppose (and INDEX it!)
Would this help?
ON A.[entrytime] >=-B.[day]
AND B.[day] < DATEADD(day, DATEDIFF(day, 0, A.[entrytime]), 1)
Maybe doing the calculation on the Remote server would do?
SELECT v_lkw, entrytime, vLkwCommon
'SELECT (200/[traveltimeLkw])*3.6 AS v_lkw, [entrytime] ,[vLkwCommon]
, DATEADD(day, DATEDIFF(day, 0, [entrytime]), 1) AS entrytime_DAY
WHERE [roadcode]= ''A23_1'' and [from2dk]>=9000 and [to2dk]<=10000'