Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #318
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Bob Barrows" <reb01501@NOyahooSPAM.com> |
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: Fred. (ghrno-google@yahoo.com) writes:isnumeric has always been useless. |
| Date | Tue, 10 May 2011 14:56:46 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 64 |
| Message-ID | <iqc32k$t3s$1@dont-email.me> (permalink) |
| References | <Xns9ED171C6FB504Yazorman@127.0.0.1> <2011510141922usenet@terrranews.com> |
| Injection-Date | Tue, 10 May 2011 19:18:44 +0000 (UTC) |
| Injection-Info | mx01.eternal-september.org; posting-host="NUmboHSNYG4cX5Ys9j8TNw"; logging-data="29820"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vjKA45WDlnFApK2aYED/9ZshHhmmIzts=" |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2800.2001 |
| X-Antivirus-Status | Clean |
| X-Newsreader | Microsoft Outlook Express 6.00.2800.2001 |
| X-Antivirus | avast! (VPS 110510-0, 05/10/2011), Outbound message |
| Cancel-Lock | sha1:nwnCZjxs7zjg4JWcg7QoBxs08d4= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| Xref | x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:318 |
Show key headers only | View raw
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:
>
<snip>
> 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?
<snip>
>>> 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.
>>>
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
Looking for faster integer validation "Fred." <ghrno-google@yahoo.com> - 2011-04-23 15:02 -0700
Re: Looking for faster integer validation Erland Sommarskog <esquel@sommarskog.se> - 2011-04-24 11:11 +0200
Re: Fred. (ghrno-google@yahoo.com) writes:isnumeric has always been useless. Pedro Eu <pedro.wtf@gmail.com> - 2011-05-10 18:19 +0000
Re: Fred. (ghrno-google@yahoo.com) writes:isnumeric has always been useless. Gene Wirchenko <genew@ocis.net> - 2011-05-10 12:01 -0700
Re: Fred. (ghrno-google@yahoo.com) writes:isnumeric has always been useless. "Bob Barrows" <reb01501@NOyahooSPAM.com> - 2011-05-10 14:56 -0400
Re: Fred. (ghrno-google@yahoo.com) writes:isnumeric has always been useless. "Fred." <ghrno-google@yahoo.com> - 2011-05-10 12:20 -0700
Re: Fred. (ghrno-google@yahoo.com) writes:isnumeric has always been useless. "Fred." <ghrno-google@yahoo.com> - 2011-05-10 12:50 -0700
csiph-web