我有一系列字符串,如:
'...abcd=123-456-ABC,email=hello@world.com,...'
我想隔离abcd
&的价值观。 email
并将它们存储在自己的变量中。
我正在使用T-SQL。
答案 0 :(得分:1)
怎么样:
Error 404: javax.servlet.UnavailableException: SRVE0200E: Servlet [XCCQuery]: Could not find required class - XCCQuery
答案 1 :(得分:1)
使用T-SQL,您可以尝试这个
DECLARE @tbl TABLE(ID INT, YourString NVARCHAR(100));
INSERT INTO @tbl VALUES
(1,N'abcd=123-456-ABC,email=hello@world.com')
,(2,N'abcd=SomeOther,email=test@world.com')
,(3,N'abcd=OneMore,other=123,AnOneMore=abc');
WITH Splitted AS
(
SELECT ID
,CAST(N'<x>' + REPLACE((SELECT YourString AS [*] FOR XML PATH('')),N',',N'</x><x>') + N'</x>' AS XML) AS InParts
FROM @tbl
)
SELECT ID
,LEFT(The.Part,CHARINDEX('=',The.Part)-1) AS Caption
,SUBSTRING(The.Part,CHARINDEX('=',The.Part)+1,1000) AS Value
FROM Splitted
CROSS APPLY Splitted.InParts.nodes('/x') AS A(B)
CROSS APPLY (SELECT B.value('.','nvarchar(max)')) AS The(Part)
结果
ID Caption Value
1 abcd 123-456-ABC
1 email hello@world.com
2 abcd SomeOther
2 email test@world.com
3 abcd OneMore
3 other 123
3 AnOneMore abc
答案 2 :(得分:0)
感谢您的回答,我能够回答我自己的问题如下:
set string1 = SUBSTRING(TEXT,CHARINDEX(&#39; abcd =&#39;,TEXT)+5,CHARINDEX(&#39;,email&#39;,TEXT) - CHARINDEX(&#39; abcd =&#39;,TEXT)-5)
set string2 = SUBSTRING(TEXT,CHARINDEX(&#39; email =&#39;,TEXT)+6,CHARINDEX(&#39;,[next variable]&#39;,TEXT) - CHARINDEX(& #39;电子邮件=&#39;,TEXT)-6)