当前位置: 代码迷 >> Sql Server >> 请问sql的字符处理写法
  详细解决方案

请问sql的字符处理写法

热度:34   发布时间:2016-04-27 12:01:45.0
请教sql的字符处理写法?
请教sql的字符处理写法?

原始格式

id name 
 1 流水号:11122-559-21223 仓库辖区B ............
 2 流水号:232-321-213 仓库辖区D ............
 3 流水号:32133-00332-21223 仓库辖区C ............
 
我想得到以下结果,sql怎么写?
id name 
 1 11122-559-21223
 2 232-321-213
 3 32133-00332-21223

------解决方案--------------------
确定name字段的格式是相同?

SQL code
select id,substring(name,charindex(':',name)+1,charindex('仓',name)-charindex(':',name)-1) as colfrom tb
  相关解决方案