I need to remove leading characters with variable zeros in my column. The string always starts with '049' + filling zeros + some number. I need to extract the number after leading zeros.
04912040 -> 12040
04901204 -> 1204
04900100 -> 100
04900012 -> 12
04900008 -> 8
I have found this solution and added replace for the leading '049' to be replaced with '000':
SUBSTRING(mycolumn, PATINDEX('%[^0]%', REPLACE(mycolumn, '049', '000')), LEN(mycolumn))
However, this won't work if my string looks like 04904901
, since instead of 4901
I will get 1
.