Reputation: 1
insert into @temp_traffic_reports(id, assetname,datestamp,messagetype,itemquantity)
(
select
tf.ID as id,
ta.TrackingIdentityName as assetname,
DATEADD(hour,@TimeZoneValue,Datestamp) as datestamp ,
'Poll for position report' as messagetype,
'1' as itemquantity
FROM trackmaps_WHB.dbo.MESForwardMessage tf
join @temp_assets ta
on tf.TerminalID = ta.TrackingIndentity
where
Datestamp between DATEADD(hour,@TimeZoneValue,@fDate) and DATEADD(hour,@TimeZoneValue,@tDate)
);
Upvotes: 0
Views: 255
Reputation: 835
insert into @temp_traffic_reports(id, assetname,datestamp,messagetype,itemquantity)
(
select
tf.ID as id,
ta.TrackingIdentityName COLLATE SQL_Latin1_General_CP1_CI_AS as assetname ,
DATEADD(hour,@TimeZoneValue,Datestamp) as datestamp ,
'Poll for position report' as messagetype,
'1' as itemquantity
FROM trackmaps_WHB.dbo.MESForwardMessage tf
join @temp_assets ta
on tf.TerminalID = ta.TrackingIndentity
where
Datestamp between DATEADD(hour,@TimeZoneValue,@fDate) and DATEADD(hour,@TimeZoneValue,@tDate)
Upvotes: 1
Reputation: 1464
insert into @temp_traffic_reports(id, assetname,datestamp,messagetype,itemquantity)
(
select
tf.ID as id,
ta.TrackingIdentityName as assetname,
DATEADD(hour,@TimeZoneValue,Datestamp) as DATES_STAMP ,
'Poll for position report' as messagetype,
'1' as itemquantity
FROM trackmaps_WHB.dbo.MESForwardMessage tf
join @temp_assets ta
on tf.TerminalID = ta.TrackingIndentity
CROSS APPLY (SELECT DATES_STAMP) AS A
WHERE A.DATES_STAMP between DATEADD(hour,@TimeZoneValue,@fDate) and DATEADD(hour,@TimeZoneValue,@tDate)
)
Upvotes: 0