字符串中截取中文或数字

来源:互联网 发布:scala map json 编辑:程序博客网 时间:2024/05/17 01:27

declare @a varchar(100),@b varchar(20)
set @a='上海的12345678'
--取出中文
select reverse(substring(reverse(@a),patindex('%[吖-座]%',reverse(@a)),len(@a)))

--取数字
select  @b=reverse(substring(reverse(@a),1,patindex('%[吖-座]%',reverse(@a))-1))