Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

isnumeric equivalent in ASE 12.5.4

822 views
Skip to first unread message

SenthilKumar

unread,
Jun 3, 2009, 9:31:55 AM6/3/09
to
Hi,
I am using ASE 12.5.4. I have a scenario where I need to
check whether a set of character (5 bytes) is numeric or
not. Could someone help me on how to achieve this in
12.5.4?

Thanks in advance for your support.

Rob V [Sybase]

unread,
Jun 3, 2009, 4:26:56 PM6/3/09
to
Assuming your string is in a variable @v (and is not empty) :

if @v like "%[^0-9]%"
begin
print "string is not numeric"
end
else
begin
print "string is numeric"
end


You can exclude spaces by adding a space to the pattern inside the brackets.

HTH,

Rob V.
-----------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 15.0/12.5/12.0/11.5/11.0
and Replication Server 15.0.1/12.5 // TeamSybase

Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks & Recipes for Sybase ASE" (ASE 15 edition)
"The Complete Sybase ASE Quick Reference Guide"
"The Complete Sybase Replication Server Quick Reference Guide"

mailto:r...@YOUR.SPAM.sypron.nl.NOT.FOR.ME
http://www.sypron.nl
Sypron B.V., Amersfoort, The Netherlands
Chamber of Commerce 27138666
-----------------------------------------------------------------

<SenthilKumar> wrote in message news:4a267b4b.300...@sybase.com...

TARTAMPION

unread,
Jun 4, 2009, 12:08:36 PM6/4/09
to
Would the following help?
suppose that the table tb1 contain the following character
data
a
-------
12345
12a45
123a4
1234a
67891
we can do the following select from it which transform the
char numeric values to integer and the non-numeric to
integer value 0


select case when a like "%[^0-9]%" then 0 else
convert(int,a) end from tb1

--------
12345
0
0
0
64891

0 new messages