I have the following where clause...Right now it is slow.It is anyway I can speed up by rewriting differently??
and ( b.ID1 = a.ID1
or b.ID2=a.ID2
or (Replicate ('0',11-len(b.ID3)) + b.ID3)=a.ID3)
AND ( a.ID1 = @ID
or (Replicate ('0',11-len(a.ID3)) + a.ID3)=@ID
or a.ID2=@ID)
and ( b.ID1 = a.ID1
or b.ID2=a.ID2
or (Replicate ('0',11-len(b.ID3)) + b.ID3)=a.ID3)
AND ( a.ID1 = @ID
or (Replicate ('0',11-len(a.ID3)) + a.ID3)=@ID
or a.ID2=@ID)