首先,让我说,这就是您首先不应该在字段中使用逗号分隔数据的原因。没有简单或有效的方法来使用它。
也就是说,您可以使用递归查询来拆分字符串并从中获取数字:
with split as( select item = cast('' as varchar(max)), source = cast('20,0, 5,,^24,0, 0,,^26,0, 0,,^281,0, 0,,^34,0, 2,,^48,0, 2,,^44,0, 2,,^20,0, 10,,^20,5, 5,,^379,1, 1,,^26,1, 2,,^32,0, 1,,^71,0, 2,,^' as varchar(max)) union all select item = substring(source, 1, charindex(',,', source)), source = substring(source, charindex(',,', source) + 2, 10000) from split where source > '')select substring(item, 1, charindex(',', item) -1)from splitwhere item > ''
结果:
20^24^26^281^34^48^44^20^20^379^26^32^71
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)