Check If String Value Has Numeric Data Or Not In SQL

Herewith, I have shared my analysis and added the solutions. order to check the varchar field for the mathematical calculation whether the varchar field value has numeric data or not.
 
We are storing the numeric and string value in the varchar. For example, $500. If we use the Isnumeric, it will return true only. In order to avoid this kindly of mirror issue, we can use the try_Cast, It will return false only.
 
When string value has this character € | + | . | , | \ | - | 12e4 |
  • isnumeric return result 1.
  • When we using try_Cast it returns 0.
See below another example,
  • $1000 is not numeric, but ISNUMERIC returns true, then proceed for the convert it as numeric.
  • Now, It says "Error converting data type varchar to numeric"
SQL
  1. DECLARE @var varchar(100)   
  2. SET @var = '$1000' SELECT ISNUMERIC(@var)   
  3. SELECT CASE   
  4. WHEN ISNUMERIC (@var) = 1   
  5. THEN CAST(@var AS numeric(36, 4))   
  6. ELSE CAST('0' AS numeric(36,4))   
  7. END  
Result
 
Check String Value Has Numeric Data Or Not In SQL
ISNUMERIC Return the varchar as True Example
 
Check String Value Has Numeric Data Or Not In SQL 
Solutions
 
In this type of case, while varchar value is used for numeric calculation. Use TRY_CAST 
  1. DECLARE @var varchar(100);   
  2. SET @var = '$1000';  
  3. SELECT ISNULL( TRY_CAST(@var AS numeric(36, 4)), 0 )