October 10, 2005 at 9:05 am
HI i have to check for numeric number inside stored procedure.. how can i achieve this..
Thanks
THNQDigital
October 10, 2005 at 9:12 am
IsNumeric is available in SQL Server:
select IsNumeric('Hello'), IsNumeric(42)
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
October 10, 2005 at 9:17 am
but can we use isnumeric inside a stored procedure..?
Create Proc test..
as
IF (LEN(@SerialNum) = 10)
SET @AgeYear = LEFT(@SerialNum,2)
IF (ISNUMERIC(@AgeYear))
BEGIN
.........etc
i get error saying incorrect syntax near ISNUMERIC.. i know books online lists isnumeric as deterministic..i don't what is wrong with above code.. please help.
THNQDigital
October 10, 2005 at 10:08 am
you have to formulate your if statement into something that returns a boolean true false
declare @ageYear varchar(10)
set @ageYear = '44'
if(isnumeric(@AgeYear) = 1)
select 'true'
else
select 'false'
October 10, 2005 at 10:19 am
That works .. Thank you..
Best Regards
THNQDigital
October 11, 2005 at 1:27 am
Take care with ISNUMERIC... it isn't what it seems :-). If what you want is to check whether all chracters in a string are numbers, then this is not 100% reliable. For example, strings like '7188E98' or '+' will be reported as numeric, that is, ISNUMERIC('+') = 1.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply