By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
WITH elbat
AS
(
SELECT 'My tax rate is 18.8% **.' column_desc
UNION ALL
SELECT '13.8% is my tax rate.' column_desc
UNION ALL
SELECT 'My tax rate 15.9% What is yours ?' column_desc
)
SELECT convert(decimal(3, 1),
substring(column_desc,
patindex('%[0-9]%',
column_desc),
len(column_desc)
- patindex('%[0-9]%',
column_desc)
- patindex('%[0-9]%',
reverse(column_desc))
+ 2)) new_value
FROM elbat;
new_value |
---|
18.8 |
13.8 |
15.9 |