Replace SQL - Replace special SQL characters with function

2

I need to replace some special characters using SQL 2008, for that to generate a function.

This is the -sql- part where the replacement is made:

   set @raw = replace(replace(@raw,'&lt;br /&gt; * ','<br/>*'),'&amp;nbsp;',' ')

This is the result:

  

Cancellation policy based on the time zone of the   Destination: < br / > < br / > * Canceling from 10/18/2016 at   00:00:00 to 10/18/2016 at 00:59:59: 0 USD < br / & gt * From   these moments until the start date of travel 10/20/2016 00:00: 1   night (s)

How can I do to replace the part of the text that comes with those special characters: &lt;br /&gt; &lt;br /&gt;

Thank you very much.

    
asked by npalle 18.10.2016 в 01:47
source

1 answer

2

If you wish at any time, retrieve that information from the database you can do it in the following way:

SET @raw = 
  Replace(
    Replace(
      Replace(@raw,'&','&amp;'),
    '<', '&lt;'),
  '>', '&gt;')

In this way it is encoded and when you recover it in the client, you decode it and the integrity of the information is maintained.

If you want to replace it with something else or simply remove it, it would be that you replace them with the text of your preference.

    
answered by 18.10.2016 / 01:51
source