문제

My string is as below :

<SL1> Locationdetails are in the table .<RXCH><cF7712>Location1<cF4712>
        <RXCS1>H1<RXCS2>H2<RXCS3>H3
        <RXC11>C11<RXC12>C12
        <RXC13>C13<RXC21>C21
        <RXC22>C22<RXC23>C23
        <RXC31>C31<RXC32>C32
        <RXC33>C33<RXC41>C41
        <RXC42>C42<RXC43>C43
        <RXC51>C51<RXC52>C52
        <RXC53>C53
        <RXCH><cF7712>Location1<cF4712>
        <RXCS1>H1<RXCS2>H2<RXCS3>H3
        <RXC11>C11<RXC12>C12
        <RXC13>C13<RXC21>C21
        <RXC22>C22<RXC23>C23
        <RXC31>C31<RXC32>C32
        <RXC33>C33<RXC41>C41
        <RXC42>C42<RXC43>C43
        <RXC51>C51<RXC52>C52
        <RXC53>C53. Services for primary health care'

I would like to split the above string and the output as below:

OUTPUT should be:

'Location1 H1 H2 H3 C11 C12 C13 C21 C22 C23 C31 C32 C33 C41 C42 C43 C51 C52 C53 Location1 H1 H2 H3 C11 C12 C13 C21 C22 C23 C31 C32 C33 C41 C42 C43 C51 C52 C53'
도움이 되었습니까?

해결책

-- Get text between points
set @str = stuff (@str, 1, charindex ('.', @str), '')
set @str = left (@str, charindex ('.', @str) - 1)
-- Get rid of spaces, tabs and line ends
set @str = replace (replace (replace (replace (@str, ' ', ''), char(9), ''), char(10), ''), char(13), '')
-- Output
select ltrim (cast(replace (@str, '>', '/> ') as xml).value('.', 'varchar(max)'))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top