Avatar of tmajor99
tmajor99
 asked on

MS SQL to detect number values plus decimals. Whole numbers and numbers with decimals only.

Need help with MS SQL statement that will check for numbers values including decimals.  Will isnumeric work for this purpose?  


Value

---------- 

100.99        Good 

$2.0             Bad 

1                  Good 

500             Good 

ABC             Bad 

000.4000      Good 

10.999999    Good

6.                    Good

-400               Bad

3/4                  Bad 

1.56 ABC       Bad 

Microsoft SQL Server

Avatar of undefined
Last Comment
Pavel Celba

8/22/2022 - Mon
ste5an

Same again, store NUMERIC() values,

For your question, there is a common accepted modus operandi: It's called testing. But you should look instead of ISNUMERIC() into TRY_PARSE() and TRY_CAST().

And about your sample data: Why is ABC 'bad'`? It is a valid hexadecimal value.
ASKER CERTIFIED SOLUTION
Pavel Celba

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck