我有一个查询
declare @strString varchar(500)
set @strString ='Terminal$Attr1,Attr2,Attr3,Attr4,Attr5,Attr6,@Connector$Con1,Con2,Con3,Con4,@Wire$W1,W2,W3,W4,W5,'
;WITH StrCTE(start, stop) AS
(
SELECT 1, CHARINDEX('$' , @strString )
UNION ALL
SELECT stop + 1, CHARINDEX(',' ,@strString , stop + 1)
FROM StrCTE
WHERE stop > 0
)
SELECT SUBSTRING(@strString , start, CASE WHEN stop > 0 THEN stop-start ELSE 4000 END) AS stringValue
FROM StrCTE
where SUBSTRING(@strString , start, CASE WHEN stop > 0 THEN stop-start ELSE 4000 END)<>''
为我提供输出:
stringValue
Terminal
Attr1
Attr2
Attr3
Attr4
Attr5
Attr6
@Connector$Con1
Con2
Con3
Con4
@Wire$W1
W2
W3
W4
W5
但我需要输出为:
stringValue
Terminal
Attr1
Attr2
Attr3
Attr4
Attr5
Attr6
Connector
Con1
Con2
Con3
Con4
Wire
W1
W2
W3
W4
W5
答案 0 :(得分:0)
使用替换(&lt;&gt;,&#39; @&#39;,&#39;&#39;)
SELECT REPLACE(SUBSTRING(@strString , start, CASE WHEN stop > 0 THEN stop-start ELSE 4000 END, '@', '') AS stringValue
答案 1 :(得分:0)
尝试在if (callbackReceived === false && results && results.length > 0) {
callbackReceived = true;
// continue as before
}
CTE