我有这个varchar字段;
Substrg
--------
38-40week
8month
7
40
38-40week
我想只获取数字,例如:
38-40
8
7
40
38-40
我试过这个,但它不起作用......:
select SUBSTRING(Substrg, PATINDEX('%[0-9]%', Substrg), LEN(Substrg))
我该怎么办?感谢
答案 0 :(得分:3)
select replace ('38-40week', SUBSTRING('38-40week', PATINDEX('%[a-z]%', '38-40week'),
LEN('38-40week')),'')