标签:sele 替换 char convert get serve strong -- weight
原文地址:http://www.maomao365.com/?p=7307
--例: -----获取下面字符串中中括号中的内容 -----我们可以将下列规则的字符串采用replace替换为XML格式的字符串,然后采用xml select获取相关信息 DECLARE @stringInfo VARCHAR(MAX) =‘1:[猫猫小屋],2:[字符串分割],3:[sql教程博客]‘ , @q VARCHAR(3) =3; ---获取第三个分割符中的信息 declare @xmlInfo xml ; set @stringInfo = ‘<xmlInfo keyId ="‘+@stringInfo; set @stringInfo = REPLACE(@stringInfo, ‘[‘, ‘" value="‘); set @stringInfo = REPLACE(@stringInfo, ‘],‘, ‘" /><xmlInfo keyId ="‘); set @stringInfo = REPLACE(@stringInfo, ‘]‘, ‘" />‘); set @stringInfo = REPLACE(@stringInfo, ‘:‘, ‘‘); set @xmlInfo = CONVERT(xml,@stringInfo); SELECT @xmlInfo as [xmlInfo], @xmlInfo.value(‘(/xmlInfo[@keyId=sql:variable("@q")]/@value)[1]‘, ‘varchar(60)‘);
mssql sqlserver 下文分享一种新颖的字符串截取方法
标签:sele 替换 char convert get serve strong -- weight
原文地址:https://www.cnblogs.com/lairui1232000/p/9534953.html