I have column having value like 'aAb314282069480098c1234d#20e000'.
I would like to get only '314282069480098' from this. How can I achieve this.
I have tried like this:
SUBSTRING(Mercury_AcqRefData,PATINDEX('%[0-9]%',Mercury_AcqRefData),LEN(Mercury_AcqRefData))
but I didn't achieve. Thanks in advance for your help.
Try below it is giving required results:
DECLARE @string varchar(200) = 'aAb314282069480098c1234d#20e000'
select left(s, patindex('%[^0-9]%', s) - 1)
FROM (SELECT SUBSTRING(@string, patindex('%[0-9]%', @string), len(@string))
as S
) XX;
Can you please try the following query:
DECLARE @Mercury_AcqRefData AS VARCHAR(200) = 'aAb31428206948220098c1234d#20e000';
DECLARE @Filter1 AS VARCHAR (200) = '';
SELECT @Filter1 = SUBSTRING(@Mercury_AcqRefData, PATINDEX('%[0-9]%', @Mercury_AcqRefData), LEN(@Mercury_AcqRefData));
SELECT SUBSTRING(@Filter1, 0, PATINDEX('%[A-Za-z]%', @Filter1));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With