From: reb01501@NOyahooSPAM.com   
      
   Pedro Eu wrote:   
   > Fred, I'm trying to use your solution but I think something is going   
      
   It wasn't Fred's solution, it was Erland's suggestion.   
      
   > wrong. Try this:   
   >   
      
   > IF '123' LIKE '%[^0-9]%'   
   > BEGIN   
   > PRINT '3rd case OK'   
   > END   
   >   
   > IF '123a' LIKE '%[^0-9]%'   
   > BEGIN   
   > PRINT '4th case OK'   
   > END   
   >   
   > Sql Server result:   
   > 1st case OK   
   > 4th case OK   
   >   
   > The 1st case is ok to me, but I do not understood why the 3rd case is   
   > not ok and the 4th is.   
   >   
   > Any idea?   
      
   Yes. You did not follow the suggested solution. Specifically, you left out   
   the "NOT" keyword:   
      
    IF '123' NOT LIKE '%[^0-9]%'   
    PRINT '''123'' contains only numeric characters'   
   ELSE   
    PRINT '''123'' contains at least one non-numeric character'   
      
   and   
      
    IF '123a' NOT LIKE '%[^0-9]%'   
    PRINT '''123a'' contains only numeric characters'   
   ELSE   
    PRINT '''123a'' contains at least one non-numeric character'   
      
      
   The pattern [^0-9] means "not 0 to 9", so the expression LIKE '%[^0-9]%'   
   returns true if any characters that are not 0 to 9 are found in the string.   
   Does that help?   
      
      
   >>> On Sunday, April 24, 2011 5:11 AM Erland Sommarskog wrote:   
   >   
   >>> Fred. (ghrno-google@yahoo.com) writes:   
   >>>   
   >>> isnumeric has always been useless.   
   >>>   
   >>> If you need to validate for unsigned integers, you can use this   
   >>> expression:   
   >>>   
   >>> col NOT LIKE '%[^0-9]%'   
   >>>   
   >>> This expression returns false, as soon there is a value which   
   >>> contains any non-digit character including space.   
   >>>   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|