我已将sybase查询更改为T-sql但由于某种原因,我无法在转换后匹配sybase查询和T-sql的结果集。请查看我的t-sql查询。任何帮助都非常感谢,因为我对sybase很新。感谢
FROM detail
, hdr
, ck
, fd
, master
, subcode
, transaction
WHERE (detail.fd_id = fd.fd_id )
AND master.id = detail.gl_id
AND (detail.period >= P_Start )
AND (detail.period <= P_End )
AND detail.version = master.version
AND ((detail.source = @source) OR (@source IS NULL) OR @source= '' OR :@source = ' ')
AND detail.ct_id *= hdr.ct_id
AND detail.inv_id *= hdr.inv_id
AND detail.ck_id *= ck.ck_id
AND detail.sub *= subcode.subcode
AND detail.tran *= transaction.transaction
AND detail.version *= transaction.version
AND fd.fd_group *= transaction.fd_group
AND ((detail._refer = @Refer) OR (ISNULL(@Refer, '') = ''))
AND (((@IntSource = 'Z') AND ((detail.int_source = @OldVoucher) OR (ISNULL(@OldVoucher,'') = '')))
AND (@ExcludeCB = 'N' OR NOT EXISTS(SELECT * FROM version_fd_group
where version_fd_group.version = detail.version and balancing_id = detail.id))
===== T-SQL ===================
FROM detail
INNER JOIN Fd
ON detail.fd_id = fd.fd_id
INNER JOIN master
ON master.id = detail.gl_id AND AND (detail.period >= P_Start )
AND (detail.period <= P_End )
AND detail.version = master.version
AND ((detail.source = @source) OR (@source IS NULL) OR @source= '' OR :@source = ' ')
LEFT OUTER JOIN hdr
ON detail.ct_id = hdr.ct_id and detail.inv_id = hdr.inv_id
LEFT OUTER JOIN ck
ON detail.ck_id = ck.ck_id
LEFT OUTER JOIN subcode
ON detail.gl_sub = subcode.subcode
LEFT OUTER JOIN transaction
ON detail.tran = transaction.transaction AND detail.version = transaction.version
LEFT OUTER JOIN transaction transaction2
ON fd.fd_group = transaction2.fd_group
WHERE
((detail._refer = @Refer) OR (ISNULL(@Refer, '') = ''))
AND (((@IntSource = 'Z') AND ((detail.int_source = @OldVoucher) OR (ISNULL(@OldVoucher,'') = '')))
AND (@ExcludeCB = 'N' OR NOT EXISTS(SELECT * FROM version_fd_group
where version_fd_group.version = detail.version and balancing_id = detail.id))