Determine if a string is numeric: Difference between revisions

Content added Content deleted
(add SQL)
Line 216: Line 216:
==[[SQL]]==
==[[SQL]]==
[[Category:SQL]]
[[Category:SQL]]
-- Tested on Microsoft SQL Server 2005
-- Tested on Microsoft SQL Server 2005

declare @s varchar(10)
declare @s varchar(10)
set @s = '1234.56'
set @s = '1234.56'

print isnumeric(@s) --prints 1 if numeric, 0 if not.
print isnumeric(@s) --prints 1 if numeric, 0 if not.

if isnumeric(@s)=1 begin print 'Numeric' end
if isnumeric(@s)=1 begin print 'Numeric' end
else print 'Non-numeric'
else print 'Non-numeric'


==[[Tcl]]==
==[[Tcl]]==