在对两个表进行联合之后,现在它忽略了我的 WHERE 语句的 @Badge 参数。代码如下。
SELECT TOP (100) PERCENT ID_BADGE, LEFT(RIGHT('000000' + CAST(TIME_TRX AS varchar), 6), 2)
+ ':' + SUBSTRING(LEFT(RIGHT('000000' + CAST(TIME_TRX AS varchar), 6), 4), 3, 2) AS ClockTime, DATE_TRX, CODE_TRX
FROM omi.DCUTRX_ZERO
UNION ALL
SELECT TOP (100) PERCENT ID_BADGE, LEFT(RIGHT('000000' + CAST(TIME_TRX AS varchar), 6), 2)
+ ':' + SUBSTRING(LEFT(RIGHT('000000' + CAST(TIME_TRX AS varchar), 6), 4), 3, 2) AS ClockTime, DATE_TRX, CODE_TRX
FROM omi.TAHIST_ZERO
WHERE (ID_BADGE = ' ' + @Badge) AND (DATE_TRX BETWEEN @Date AND @Date2) AND (SEQ_REC IN ('0', '1000')) AND (CODE_TRX IN ('100', '101'))
任何帮助是极大的赞赏!