我知道下面的查询不是最好的,但现在它必须完成这项工作:
FROM dbo.CE_Summons_ext0 s with (nolock)
INNER JOIN dbo.CE_Fines_ext0 f with (nolock)
ON (f.ref_no = s.ref_no AND f.doc_type = s.doc_type)
INNER JOIN dbo.CE_charge_status c with (nolock)
ON f.status = c.status_no
INNER JOIN dbo.CE_COURT_DESC crt_desc with (nolock)
ON crt_desc.COURT = s.COURT
INNER JOIN dbo.CE_CntParms_ext0 param with (nolock)
ON param.REF_NO = s.ref_no
INNER JOIN dbo.CE_Court_result crt_result with (nolock)
ON crt_result.COURT_RESULT = param.COURT_RESULT
WHERE s.SUMMONS_NO = isnull(nullif(@sms_summons_no, ''), s.SUMMONS_NO)
AND s.ref_no = isnull(nullif(@scp_ref_no,''), s.ref_no)
AND s.COURT = isnull(nullif(@sms_court,'') , s.COURT)
-- AND f.STREET1 = isnull(nullif(@street1,''), f.STREET1)
-- AND f.acc_name = isnull(nullif(@offender_name,''), f.acc_name)
-- AND f.id_no = isnull(nullif(@offender_id,''), f.id_no)
-- AND f.acc_name = isnull(nullif(@owner_name,''), f.acc_name)
-- AND f.id_no = isnull(nullif(@owner_id,''), f.id_no)
END
WHERE
如果我取消注释最后一个条件,它的运行速度非常慢。我究竟做错了什么?