I am trying to run a query and it works fine when running the below query:
SELECT 'Delivery' activity_type,
left(pod.ID1, charindex('*', pod.ID1) - 1) load_number,
DATEADD(hour, CONVERT(INT, LEFT(CONVERT(VARCHAR(2), ISNULL(Dock_In_Time,
'0')), 2)), CONVERT(DATETIME, ID2)) expected_arrival
FROM [Server].[Database].[dbo].[POD_Sched_Del] pod
--WHERE expected_arrival between '6/7/18' and '6/8/18'
ORDER BY expected_arrival asc, activity_type
When I add in the following line of code that is in the comment:
--WHERE expected_arrival between '6/7/18' and '6/8/18'
I get these error messages:
Msg 207, Level 16, State 3, Line 37 Invalid column name 'expected_arrival'.
Msg 207, Level 16, State 3, Line 37 Invalid column name 'expected_arrival'.