select * from @tbMN a where not exists ( select * from ModelLossInfo where ModelName=a.ModelName and PN=a.PartNumber and LineName=@LineName and CONVERT(varchar(12),ScanDate,23)=convert(varchar(12),@ScanDate,23)