![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, How to match a string containing only numbers? The below method doesn't works. Please help. declare @s varchar(30) select @s="123" if(@s like '[0-9]') * *print "This string contains only numbers" else * *print "This string contains special characters" Thanks, |
#3
| |||
| |||
|
|
Hi, How to match a string containing only numbers? The below method doesn't works. Please help. declare @s varchar(30) select @s="123" if(@s like '[0-9]') print "This string contains only numbers" else print "This string contains special characters" Thanks, |
#4
| |||
| |||
|
|
"Subind" <subind123 (AT) gmail (DOT) com> wrote in message news:41680f6c-c15a-4d43-89f5-ea5fc7d21ef6 (AT) f11g2000vbf (DOT) googlegroups.com... Hi, How to match a string containing only numbers? The below method doesn't works. Please help. declare @s varchar(30) select @s="123" if(@s like '[0-9]') print "This string contains only numbers" else print "This string contains special characters" Thanks, For your particular example ("123") it could be if (@s) like '[0-9][0-9][0-9]') If you are on 15.0.1 or later use if (isnumeric (@s) = 1) At the moment I can't think of a more general solution (since you use a varchar (30) and I assume that the arguments can be anything from NULL up to 30 characters "long"). |
#5
| |||
| |||
|
|
Hi, How to match a string containing only numbers? The below method doesn't works. Please help. declare @s varchar(30) select @s="123" if(@s like '[0-9]') * *print "This string contains only numbers" else * *print "This string contains special characters" Thanks, |
#6
| |||
| |||
|
|
On Jan 6, 12:54 pm, Subind <subind... (AT) gmail (DOT) com> wrote: Hi, How to match a string containing only numbers? The below method doesn't works. Please help. declare @s varchar(30) select @s="123" if(@s like '[0-9]') print "This string contains only numbers" else print "This string contains special characters" Thanks, Do you mean "numbers" or "numeric digits"? i.e., in terms of your problem, are any of the following strings "numbers"? 1.0 -1 2.3e58 -2.3e-65 INF NAN -0.0 one thousand, two hundred and fifty-four cinco ichi 0xff |
![]() |
| Thread Tools | |
| Display Modes | |
| |