ISNUMERIC equivalent

  • HI i have to check for numeric number inside stored procedure.. how can i achieve this..

    Thanks

    THNQDigital 

  • IsNumeric is available in SQL Server:

    select IsNumeric('Hello'), IsNumeric(42)

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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

  • 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'

  • That works .. Thank you..

    Best Regards

    THNQDigital

  • 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