473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

ISNUMERIC and CAST

SELECT ISNUMERIC('. ')

1

SELECT CAST('. ' AS [insert any numeric type])

Syntax error converting the varchar value '. ' to a column of data type
[insert any numeric type].

Any thoughts as to why SQL Server 7.0 considers '. ' to be numeric, yet can't
convert it to any numeric data type? The BOL even has this to say: "ISNUMERIC
returns 1 when the input expression evaluates to a valid integer, floating
point number, money or decimal type; otherwise it returns 0. A return value of
1 guarantees that expression can be converted to one of these numeric types."

An application that has worked for years, failed when a field of type CHAR(3)
(that should be an area code) contained a period only. I have error-checking
that tests ISNUMERIC on that field, and if it fails, alert accordingly. If it
passes, then convert it to a number, and compare it to acceptable ranges for
Area Code. (200 < AC < 999)

oops...

Jul 20 '05 #1
3 16682
DCM Fan (dc****@aol.comSPNOAM) writes:
SELECT ISNUMERIC('. ')

1

SELECT CAST('. ' AS [insert any numeric type])

Syntax error converting the varchar value '. ' to a column of data type
[insert any numeric type].

Any thoughts as to why SQL Server 7.0 considers '. ' to be numeric, yet
can't convert it to any numeric data type?


You are not trying hard enough. SELECT CAST('. ' as money) returns
a value.

isnumeric() is a completely useless function. I would strongly
recommend against use of it.


--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
<<You are not trying hard enough.>>

Apparently not. I got bored after trying int, real, numeric, float and decimal.
That's why I come to this board, because I know someone else will (or has) put
in the time. Thank you.

<<isnumeric() is a completely useless function. I would strongly
recommend against use of it.>>

Nice.

I'm using PATINDEX now.
Jul 20 '05 #3
If you want to check for only integer digits, try LIKE:

SELECT *
FROM MyTable
WHERE NOT MyData LIKE ''%[^0-9]%' AND MyData <> ''

--
Hope this helps.

Dan Guzman
SQL Server MVP

"DCM Fan" <dc****@aol.comSPNOAM> wrote in message
news:20***************************@mb-m17.aol.com...
<<You are not trying hard enough.>>

Apparently not. I got bored after trying int, real, numeric, float and decimal. That's why I come to this board, because I know someone else will (or has) put in the time. Thank you.

<<isnumeric() is a completely useless function. I would strongly
recommend against use of it.>>

Nice.

I'm using PATINDEX now.

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DCM Fan | last post by:
SELECT ISNUMERIC('. ') 1 SELECT CAST('. ' AS ) Syntax error converting the varchar value '. ' to a column of data type . Any thoughts as to why SQL Server 7.0 considers '. ' to be...
8
by: eje | last post by:
IsNumeric(value) should return false if value "can not be successfully converted to a Double." Instead I get the following error message: "Input string was not in a correct format." I use the...
14
by: Kenny | last post by:
Hello, I would like to know if the function IsNumeric requires a header like #include <iostream> to be functionnal thanks ken
8
by: John Bowman | last post by:
Hello, Does anyone have a good/reliable approach to implementing an IsNumeric() method that accepts a string that may represent a numerical value (eg. such as some text retrieved from an XML...
10
by: michele | last post by:
I have a problem with VB.Net and IsNumeric() function because it always returns FALSE even the string can be a number. There is another strange thing, the same program (it is a test) runs good on...
7
by: Nathan Truhan | last post by:
All, I think I may have uncovered a bug in the IsNumeric function, or at least a misunderstanding on functionality. I am writing a Schedule Of Classes Application for our campus and have a...
12
by: sck10 | last post by:
Hello, I am trying to determine if a value is NOT numeric in C#. How do you test for "Not IsNumeric"? protected void fvFunding_ItemInserting_Validate(object sender, FormViewInsertEventArgs...
4
by: sck10 | last post by:
Hello, I am trying to test for IsNumeric using C# with the following: public bool IsNumeric(object TestValue) { try { int i = Convert.ToInt32(TestValue.ToString()); return true;
17
by: MLH | last post by:
I have tested the following in immed window: ?isnumeric(1) True ?isnumeric(1.) True ?isnumeric(1.2) True ?isnumeric(1.2.2)
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.