以下のクエリが最適ではないことはわかっていますが、今はそれでうまくいく必要があります。
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
最後の条件のコメントを外すと、条項で非常に遅くなります。私は何を間違っていますか?