需要将Sybase查询转换为SQL Server 2012

时间:2014-09-15 09:09:12

标签: sql-server tsql sql-server-2012 sybase

SELECT     
         gasqlty_cylinder.qualification_date,   
         gas_qlty_cylinder.location_id,   
         gas_qlty_lab.lab_desc,   
         gas_qlty_cylinder.start_date,   
         gas_qlty_cylinder.end_date,   
         analysis_data.date_set,   
         analysis_data.date_removed,   
         analysis_data.btu,   
         analysis_data.spec_gvty,   
         gas_qlty_cylinder.remarks,   
         gas_qlty_cylinder.mcsusr_id,   
         gas_qlty_cylinder.trans_timestamp  
FROM     gasqltycylinder,   
         analysisdata ,  
         gasqltylocation,   
         gasqltylab  
WHERE    ( gas_qlty_cylinder.cylinder_id *= analysis_data.`cylinder_id` ) and  
         ( gas_qlty_location.location_id = gas_qlty_cylinder.location_id ) and
         ( gas_qlty_location.lab_id = gas_qlty_lab.lab_id ) and  
         ( analysis_data.analyzed_time =* ( select max(analyzed_time) from analysis_data 
    where gas_qlty_cylinder.cylinder_id = analysis_data.cylinder_id and
    ))   
Order by cylinder_id

1 个答案:

答案 0 :(得分:0)

* =和= *样式联接为deprecated since SQL Server 2008discontinued in SQL Server 2012

重写您的查询,* =是LEFT OUTER JOIN和= * RIGHT OUTER JOIN。一些快速指南,其中包含MS的示例:link

此外,从查询中删除`符号。