Reputation: 139
See the following code:
select no_
from dbo.customer
where no_ like '5%%%%%'
Upvotes: 1
Views: 2525
Reputation: 1605
i would also add isnumeric
select no_ from dbo.customer where no_ like '5_____' and ISNUMERIC(no_) = 1
Upvotes: 0
Reputation: 36087
Use:
select no_ from dbo.customer where no_ like '5_____'
LIKE operator recognizes two wildcard characters :
Upvotes: 3
Reputation: 1269503
Well, you would do:
select no_ from dbo.customer where no_ like '5%'
%
is a wildcard that matches any number of characters, including none.
If you want to guarantee exactly 6 characters as well:
select no_ from dbo.customer where no_ like '5_____'
_
is a wildcard that matches exactly one character.
Upvotes: 1