i am not sure if it is possible with sql. i am trying to bring all numeric value from string.
declare @mytable table
(
myvalue varchar (50)
)
insert @mytable
select 'DOBIH3HA3' UNION ALL
select 'TAARE567ZAMEEN5' UNION ALL
select 'GAG645JAMU43'
The below approach is very closed but not getting the desired output.
SELECT LEFT(subsrt, PATINDEX('%[^0-9]%', subsrt + 't') - 1)
FROM (
SELECT subsrt = SUBSTRING(myvalue, pos, LEN(myvalue))
FROM (
SELECT myvalue, pos = PATINDEX('%[0-9]%', myvalue)
FROM @mytable
) d
) t
Please share your expertise.... Thanks a lot