Reputation: 5446
How to get valid value from the following query
SELECT Answer FROM table
WHERE values LIKE '%[^0-9]%'
Basically I want the data can deal for
Thanks
Upvotes: 1
Views: 77
Reputation: 51904
you could do something like:
select replace(replace(values, '$', ''), ',', '') as number from table
where dbo.RegexMatch(values, ^\$?(\d+|(\d{1,3}(,\d{3})+))(\.\d+)?$')
tweak the regex to match any conditions you need...
Upvotes: 1
Reputation: 78840
SELECT Answer
FROM table
WHERE
ISNUMERIC(values)
OR (
SUBSTRING(values, 1, 1) = '$'
AND ISNUMERIC(RIGHT(values, LEN(values) - 1)))
Upvotes: 1