2015-10-14 71 views
0
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) 
); 

回答

0

你必須強迫兩個排序規則中的一個表的比較

0
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) 
) 
1
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) 
之間的排序規則衝突
相關問題