|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 7:32 AM
Points: 1,059,
Visits: 1,396
|
|
| Comments posted to this topic are about the item ISNUMERIC
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 9:45 AM
Points: 2,163,
Visits: 2,151
|
|
Thanks for the question.
This should be good to help people understand how ISNUMERIC works...
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Wednesday, July 25, 2012 9:04 PM
Points: 542,
Visits: 187
|
|
| Good Question I got lost in Union all.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, November 25, 2012 6:31 PM
Points: 1,375,
Visits: 173
|
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:15 AM
Points: 1,479,
Visits: 1,943
|
|
UMG Developer (9/25/2010) Thanks for the question.
This should be good to help people understand how ISNUMERIC works...
<rant> Yeah... like total crap. Its borderline useless. Just to further demonstrate that.
select isnumeric('2e1') This gives 1! An 'e' isnt in my book numeric. Now i know SQL thinks its a calculator and thinks '2e1' = 20 (it does the same with a 'd' instead of the 'e'). But seriously, thats stupid.
Even more stupid is that even though SQL thinks this is 20 you cant convert it to an Int. You can however convert it to a Float... then to an Int... sigh.
.NET doesnt do this. Old VB6 does... but atleast VB accepts it as a Int so its consistant. SQL is divided and isnt sure abouts its decision if it really is numeric or not. </rant off>
/T
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: 2 days ago @ 6:30 AM
Points: 9,410,
Visits: 6,495
|
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:15 AM
Points: 1,479,
Visits: 1,943
|
|
da-zero (9/27/2010) Good question, although I seem to remember that I've seen similar ones.
But I don't think that considering scientific notation as numeric is stupid. 2e1 is just another way writing 20, so it is still a number. I think the reason why you can't immediately convert it to an int is because of how SQL Server handles the scientific notation. But I can't seem to find any references on that.
And how exactly do you know that '2e1' is a "scientific notation"? Could be there by accident so the value should actually have been 21 (blackjack anyone?). Now that error just slipped us by because SQL "tries" to think.
/T
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 8:24 AM
Points: 1,272,
Visits: 4,309
|
|
da-zero (9/27/2010) Good question, although I seem to remember that I've seen similar ones.
I'm sure there's been a very similar one in the past two or three months--I forget exactly when it was, though.
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: 2 days ago @ 6:30 AM
Points: 9,410,
Visits: 6,495
|
|
tommyh (9/27/2010)
da-zero (9/27/2010) Good question, although I seem to remember that I've seen similar ones.
But I don't think that considering scientific notation as numeric is stupid. 2e1 is just another way writing 20, so it is still a number. I think the reason why you can't immediately convert it to an int is because of how SQL Server handles the scientific notation. But I can't seem to find any references on that.And how exactly do you know that '2e1' is a "scientific notation"? Could be there by accident so the value should actually have been 21 (blackjack anyone?). Now that error just slipped us by because SQL "tries" to think. /T
How do you know 1+1 isn't 11 instead of 2? Maybe someone just typed in a + by accident. Let's just abandon all arithmetic operators, because SQL Server tries to think...
How to post forum questions. Need an answer? No, you need a question. What’s the deal with Excel & SSIS?
Member of LinkedIn. My blog at LessThanDot.
 MCSA SQL Server 2012 - MCSE Business Intelligence
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:15 AM
Points: 1,479,
Visits: 1,943
|
|
da-zero (9/27/2010)
tommyh (9/27/2010)
da-zero (9/27/2010) Good question, although I seem to remember that I've seen similar ones.
But I don't think that considering scientific notation as numeric is stupid. 2e1 is just another way writing 20, so it is still a number. I think the reason why you can't immediately convert it to an int is because of how SQL Server handles the scientific notation. But I can't seem to find any references on that.And how exactly do you know that '2e1' is a "scientific notation"? Could be there by accident so the value should actually have been 21 (blackjack anyone?). Now that error just slipped us by because SQL "tries" to think. /T How do you know 1+1 isn't 11 instead of 2? Maybe someone just typed in a + by accident. Let's just abandon all arithmetic operators, because SQL Server tries to think... 
True but atleast 1 and 1 are both numeric both in and out off context. Wheras "e" is only valid under some circumstances. With "11" you can do any SubString and still get a valid number. Try doing that on "2e1". Substring('2e1', 1, 2)... valid number... no.
/T
|
|
|
|