Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First take a look</p> <p>the string can contain some of these patterns</p> <pre><code> sometext&lt;p&gt;sometext&lt;/p&gt;sometext sometext&lt;p&gt;sometext&lt;/p&gt; &lt;p&gt;sometext&lt;/p&gt;sometext &lt;p&gt;sometext&lt;/p&gt; sometext&lt;/p&gt; &lt;p&gt;sometext sometext </code></pre> <p>if you want reduce risk so should be considered previous patterns so, well it is the example</p> <pre><code> declare @mem table(id int identity(1,1), NotificationMessage varchar(80)) insert into @mem(NotificationMessage) select 'that is some text initial&lt;p&gt; one two three four &lt;/p&gt; asdf asdf asdf' insert into @mem(NotificationMessage) select '&lt;p&gt; one two three four &lt;/p&gt; asdf asdf asdf' insert into @mem(NotificationMessage) select 'that is some text initial&lt;p&gt; one two three four &lt;/p&gt;' insert into @mem(NotificationMessage) select '&lt;p&gt; one two three four &lt;/p&gt;' insert into @mem(NotificationMessage) select 'one two three four &lt;/p&gt;' insert into @mem(NotificationMessage) select 'one two three four' select NotificationMessage, case when CHARINDEX('&lt;P&gt;',NotificationMessage) &gt; 1 then SUBSTRING(NotificationMessage,1,CHARINDEX('&lt;P&gt;',NotificationMessage)-1) else '' end as section1, REPLACE(SUBSTRING(NotificationMessage, case when CHARINDEX('&lt;P&gt;' , NotificationMessage) &gt; 0 then CHARINDEX('&lt;P&gt;' , NotificationMessage) + 3 else 1 end, case when CHARINDEX('&lt;/P&gt;', NotificationMessage) &gt; 0 then CHARINDEX('&lt;/P&gt;' , NotificationMessage) else LEN(NotificationMessage) end - case when CHARINDEX('&lt;P&gt;' , NotificationMessage) &gt; 0 and CHARINDEX('&lt;/P&gt;', NotificationMessage) &gt; 0 then CHARINDEX('&lt;P&gt;' , NotificationMessage) + 3 else 1 end) , ' ' ,'&amp;nbsp;') as section2, case when CHARINDEX('&lt;/P&gt;',NotificationMessage) &gt; 1 then case when len(NotificationMessage) &gt; (CHARINDEX('&lt;/P&gt;',NotificationMessage) + 4) then SUBSTRING(NotificationMessage,CHARINDEX('&lt;/P&gt;',NotificationMessage)+4, len(NotificationMessage) - CHARINDEX('&lt;/P&gt;',NotificationMessage)+4 ) else '' end else '' end as section3, case when CHARINDEX('&lt;P&gt;',NotificationMessage) &gt; 1 then SUBSTRING(NotificationMessage,1,CHARINDEX('&lt;P&gt;',NotificationMessage)-1) else '' end + REPLACE(SUBSTRING(NotificationMessage, case when CHARINDEX('&lt;P&gt;' , NotificationMessage) &gt; 0 then CHARINDEX('&lt;P&gt;' , NotificationMessage) + 3 else 1 end, case when CHARINDEX('&lt;/P&gt;', NotificationMessage) &gt; 0 then CHARINDEX('&lt;/P&gt;' , NotificationMessage) else LEN(NotificationMessage) end - case when CHARINDEX('&lt;P&gt;' , NotificationMessage) &gt; 0 and CHARINDEX('&lt;/P&gt;', NotificationMessage) &gt; 0 then CHARINDEX('&lt;P&gt;' , NotificationMessage) + 3 else 1 end) , ' ' ,'&amp;nbsp;') + case when CHARINDEX('&lt;/P&gt;',NotificationMessage) &gt; 1 then case when len(NotificationMessage) &gt; (CHARINDEX('&lt;/P&gt;',NotificationMessage) + 4) then SUBSTRING(NotificationMessage,CHARINDEX('&lt;/P&gt;',NotificationMessage)+4, len(NotificationMessage) - CHARINDEX('&lt;/P&gt;',NotificationMessage)+4 ) else '' end else '' end as newstring from @mem </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload