2
Answers

How to remove the table tr td in sql server

narasiman rao

narasiman rao

7y
223
1
  i have one table in that table i have one column in that record as follows
 
         SummaryList  record as follows
 
<table WIDTH="100%"CELLPADDING="1"CELLSPACING="1">
 
<tr style="COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 10pt;BACKGROUND-COLOR: #f2f2f2;">
   <td><b>Report Date : </b>2016-11-21 </td>
  <td><b>Optometrist : </b> </td>
  <td><b>Start Time : </b> </td>
</tr>
 
<tr style="COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 10pt;BACKGROUND-COLOR: #f2f2f2;">
        <td><b>Consultant : </b>Dr.Suresh </td>
</tr>
 
</table>
 i want to remove table tr  td and i want only content as follows
 
 
  from the above i want output as follows
 
 Report Date: 2016-11-21 Optometrist: start Time: Consultant: Dr.suresh
 
for that how to do using sql server 
Answers (2)
0
Laxmidhar Sahoo
NA 2.3k 1.4k 7y
<b> Report Date:&nbsp;&nbsp; 2016-11-21 &nbsp;&nbsp;Optometrist: &nbsp;&nbsp;start &nbsp;&nbsp;Time:&nbsp;&nbsp; Consultant: &nbsp;&nbsp;Dr.suresh</b>
0
Midhun T P
NA 19.7k 281.2k 7y
Hi,
 
Please try below query - 
  1. DECLARE @x XML = '<table WIDTH="100%" CELLPADDING="1" CELLSPACING="1">  
  2.    
  3. <tr style="COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 10pt;BACKGROUND-COLOR: #f2f2f2;">  
  4.    <td><b>Report Date : </b>2016-11-21 </td>  
  5.   <td><b>Optometrist : </b> </td>  
  6.   <td><b>Start Time : </b> </td>  
  7. </tr>  
  8.    
  9. <tr style="COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 10pt;BACKGROUND-COLOR: #f2f2f2;">  
  10.         <td><b>Consultant : </b>Dr.Suresh </td>  
  11. </tr>  
  12.    
  13. </table>'  
  14.   
  15. SELECT t.c.value('.''NVARCHAR(MAX)')  
  16. FROM @x.nodes('*') t(c)  
 
Reference :
https://stackoverflow.com/questions/38868364/sql-remove-all-html-tags-in-a-string