Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL way of checking for not numerics?

Status
Not open for further replies.

Wyldcard9

Programmer
Feb 5, 2004
82
US
Please bear with me. I am a Mainframe programmer by trade, who has been given a SQL server to work with. I am going to buy a SQL book tonight, and bring it work since we have none. I am trying to find a way to check a field for being not numeric. The guy who set up our database made everything string fields, including fields that should only be numeric. I searched the site and found nothing on numeric.

SELECT *
FROM [elvis].[EP3_14]
WHERE ID_1005 IS NOT NUMERIC

This gets a parse error. I have also tried it with an equals sign, and <> signs. It then tells me that NUMERIC is not an item(field) on the table. We are using Microsoft SQL Server.

Any guidance you can offer is greatly appreciated.

Thanks
 
Try this structure:
Code:
select * 
from MyTable 
where ISNUMERIC(MyValue)=1
Modify for your exact needs...

~Brian
 
I am sorry, the above example was for checking if a value IS numeric.

Try this instead to return non numeric values:
Code:
select * 
from MyTable 
where ISNUMERIC(MyValue)=0

~Brian
 
Code:
WHERE ISNUMERIC(ID_1005) = 1

SQL Server comes with Books Online, a really good reference. The Microsoft manual Transact SQL Reference is also very good. Transact-SQL Programming from O'Reilly is good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top