Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written the code as
declare @phone varchar(10)
set @phone='01234567891'
if @phone like '%[^0-9{1,9}]%'
print 'Y'
else 
print 'N'

where i want to allowed only value in range of 1 to 9 as per the wildcard but its not working why?
Posted
Updated 26-Mar-14 23:13pm
v2

1 solution

SQL
declare @vchar varchar(50)
set @vchar ='0124667891';
select case when @vchar not like '%[^0-9]%' then 'Number' else 'Not a Number' end
 
Share this answer
 
Comments
vishal_h 27-Mar-14 7:47am    
what {1,9} represent in wildcard
King Fisher 27-Mar-14 8:57am    
isn't work?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900