I would assume that account number is an INT, but here is a sample that might help you solve your issue using the LIKE clause:DECLARE @Acct TABLE (AccountNum VARCHAR(20), Name VARCHAR(20))INSERT @AcctSELECT '12345', 'Opt1'UNION ALL SELECT '22345', 'Opt2'UNION ALL SELECT '56346', 'Opt3'DECLARE @Pattern VARCHAR(20)SET @Pattern = '1?3??'-- SET @Pattern = '??3??' SET @Pattern = REPLACE(@Pattern, '?', '_')SELECT *FROM @AcctWHERE AccountNum LIKE @Pattern
EDIT: damn too slow again. :)