﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Ron Moses  / ISNUMERIC() and REPLICATE() / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 16:33:17 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>It's a bug in the engine, and I'm not sure how many people will run across it, but it might be nice to know this.The explanation has been changed.</description><pubDate>Tue, 24 Nov 2009 08:03:49 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>[quote][b]crussell-931424 (11/24/2009)[/b][hr]Any number of zeros returns 1. So if it is smart enough to know that all the characters are zero and thus must be a number why can't it just check all the characters individually to see if they are 0 to 9? Or is there no such thing as a number larger than a float's maximum value? I just now noticed that it strips away all leading zeros. I guess that answers my own question.  SELECT ISNUMERIC(REPLICATE('0', 7690) + REPLICATE('1', 310))  returns 0SELECT ISNUMERIC(REPLICATE('0', 7691) + REPLICATE('1', 310))  returns 1The reason then that the second one returns 1 is that there are really only 309 of them. It only considers the first 8000 characters of the string, meaning there are really only 309 of the digit 1, which we already know returns a 1.[/quote]i agree 0= 000 but 1 &amp;lt;&amp;gt; 111</description><pubDate>Tue, 24 Nov 2009 07:17:32 GMT</pubDate><dc:creator>crashdan</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>Any number of zeros returns 1. So if it is smart enough to know that all the characters are zero and thus must be a number why can't it just check all the characters individually to see if they are 0 to 9? Or is there no such thing as a number larger than a float's maximum value? I just now noticed that it strips away all leading zeros. I guess that answers my own question.  SELECT ISNUMERIC(REPLICATE('0', 7690) + REPLICATE('1', 310))  returns 0SELECT ISNUMERIC(REPLICATE('0', 7691) + REPLICATE('1', 310))  returns 1The reason then that the second one returns 1 is that there are really only 309 of them. It only considers the first 8000 characters of the string, meaning there are really only 309 of the digit 1, which we already know returns a 1.</description><pubDate>Tue, 24 Nov 2009 07:16:17 GMT</pubDate><dc:creator>crussell-931424</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>Not an every day problem for us (hi from France ^^ ), but as we have to communicate in english for international, it is an usual question :D</description><pubDate>Tue, 24 Nov 2009 07:16:00 GMT</pubDate><dc:creator>Dude76</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>[quote][b]dun (11/24/2009)[/b][hr]That's a big number. How do you report that on your financials? Numbers represented in $000,000,...,000,000? :-PIt made me do a search on the net for big number names (see [url]http://www.sizes.com/numbers/big_numName.htm[/url]). It was interesting to find that the number 1 billion can mean something different in other countries. Fantastic.[/quote]You have now ruined my morning ... HAHA ... i am doing the same.</description><pubDate>Tue, 24 Nov 2009 07:08:41 GMT</pubDate><dc:creator>crashdan</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>That's a big number. How do you report that on your financials? Numbers represented in $000,000,...,000,000? :-PIt made me do a search on the net for big number names (see [url]http://www.sizes.com/numbers/big_numName.htm[/url]). It was interesting to find that the number 1 billion can mean something different in other countries. Fantastic.</description><pubDate>Tue, 24 Nov 2009 06:51:21 GMT</pubDate><dc:creator>dun</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>I can only assume the issue with replicating 610 zeros is the number property of zero. But regardless that is a good catch ... made me think a bit. :-D</description><pubDate>Tue, 24 Nov 2009 06:22:49 GMT</pubDate><dc:creator>crashdan</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>I was a little lucky on that question because i didn't remember the limit of a float was 1,79E+308 (so 309 length), i thought of a very shortener length !309/310, close question about float limit string representation ! :)</description><pubDate>Tue, 24 Nov 2009 06:19:33 GMT</pubDate><dc:creator>Dude76</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>I would be happy to correct the explanation but I can find no means of doing so.  I assume this ability is restricted to administrators, or else it is very difficult to find.</description><pubDate>Tue, 24 Nov 2009 06:11:06 GMT</pubDate><dc:creator>ronmoses</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>The answer is not completely accurate stating that 'any string longer than 309' will return zero.SELECT ISNUMERIC(REPLICATE('0', 610)) returns '1'.Ray</description><pubDate>Tue, 24 Nov 2009 06:05:35 GMT</pubDate><dc:creator>Ray Festino</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>[quote][b]ZeroFusion (11/24/2009)[/b]As for the length constraint - according to the [url=http://msdn.microsoft.com/en-us/library/aa258271%28SQL.80%29.aspx]MS SQL Data Types[/url] list, "Floating precision number data with the following valid values: -1.79E + 308 through -2.23E - 308, 0 and 2.23E + 308 through 1.79E + 308". Such numbers have 309 digits - hence the limitation....So numbers between 1.79E + 308 and 2.23E + 308 seem not to be taken into account.[/quote]There's a typo in BOL2000. The correct range is "-1.79E + 308 through -2.23E - 308, 0 and 2.23E - 308 through 1.79E + 308".[quote]ISNUMERIC() returns a 0 against [b]any[/b] string longer than 309 characters, even if it is numeric.[/quote]Is this considered to be an explanation? This is completely incorrect. There are many 310-, 311-, and even 600-character long strings for which ISNUMERIC returns a nonzero value, for example:[code="sql"]SELECT    ISNUMERIC('-' + REPLICATE('1', 309)),    ISNUMERIC('+' + REPLICATE('1', 309) + '.'),    ISNUMERIC(REPLICATE('1', 300) + '.' + REPLICATE('1', 299))[/code]These strings can be converted to the [b]float[/b] data type. So ISNUMERIC() returns 1 as a result.Please correct the explanation... [b]ZeroFusion[/b] said about data type conversions - that's the reason.Anyway, thanks to the author for making me to do some investigation about SQL Server data types and data type conversions. It was quite interesting :-)</description><pubDate>Tue, 24 Nov 2009 03:00:47 GMT</pubDate><dc:creator>vk-kirov</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>Zerofusion - thanks for clearing my doubt.</description><pubDate>Tue, 24 Nov 2009 01:42:56 GMT</pubDate><dc:creator>Saurabh Dwivedy</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>Sauirabh, IsNumeric() returns 1 if the parameter could be converted to a number - but it doesn't have to be a numeric. So IsNumerc('123') will return 1, because you can easily convert string '123' to a number 123. More information can be found in [url=http://msdn.microsoft.com/en-us/library/ms186272.aspx]MSDN article[/url] on IsNumeric().As for the length constraint - according to the [url=http://msdn.microsoft.com/en-us/library/aa258271%28SQL.80%29.aspx]MS SQL Data Types[/url] list, "Floating precision number data with the following valid values: -1.79E + 308 through -2.23E - 308, 0 and 2.23E + 308 through 1.79E + 308". Such numbers have 309 digits - hence the limitation.However, either I don't understand something or there's something wrong, because my MS SQL 2005 installation returns the following:[code="sql"]-- Returns 0, 1 respectivelySELECT IsNumeric('2' + REPLICATE('0', 308)), IsNumeric('179' + REPLICATE('0', 306));[/code]So numbers between 1.79E + 308 and 2.23E + 308 seem not to be taken into account.</description><pubDate>Tue, 24 Nov 2009 01:29:37 GMT</pubDate><dc:creator>ZeroFusion</dc:creator></item><item><title>RE: ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>Why so, though? First, why does ISNUMERIC return 1 when obviously parameter is of type char and not numeric? And then even assuming that a string of 1's can be treated as numeric because it has nothing but numbers in it why the limit to 309? Can anyone throw some light?</description><pubDate>Tue, 24 Nov 2009 00:57:33 GMT</pubDate><dc:creator>Saurabh Dwivedy</dc:creator></item><item><title>ISNUMERIC() and REPLICATE()</title><link>http://www.sqlservercentral.com/Forums/Topic823624-1694-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/T-SQL/67990/"&gt;ISNUMERIC() and REPLICATE()&lt;/A&gt;[/B]</description><pubDate>Mon, 23 Nov 2009 21:42:51 GMT</pubDate><dc:creator>ronmoses</dc:creator></item></channel></rss>