473,473 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 16688
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.