Solved

REPLACE a certain string in a certain field

Posted on 2014-04-15
2
190 Views
Last Modified: 2014-04-15
Hi there,

I have hundreds of  text strings in a specific field of a certain table with none or exactly these two "words": <semantics> and  </semantics>

I want to REPLACE the whole string presented, BUT excluding the two above "words" present at them, if it is the case.

Example: one possible data contained in the field is:

<p>Question 06: If  <math>   <semantics>    <mrow>     <mtext>&#8201;</mtext><mtext>&#8201;</mtext><mi>x</mi><mo>+</mo><mi>y</mi><mo>=</mo><mi>a</mi><mtext>&#8201;</mtext><mtext>&#8201;</mtext><mtext>&#8201;</mtext>    </mrow>    <annotation encoding='MathType-MTEF'>MathType@MTEF@5@5@+=feaagCart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbwvMCKfMBHbqedmvETj2BSbqefm0B1jxALjhiov2DaerbuLwBLnhiov2DGi1BTfMBaebbnrfifHhDYfgasaacH84rpq0xbbf9q8WrFfeuY=Hhbbf9v8qqGqFr0xc9LqFj0lXxbba9Lqpepi0xhr=Fc9vqpeuj0lXdb9GqFj0dd9qqaqpi0xe9Gq=Fhrpe0dc8meaabaqaciaacaGaaeqabaWaaqaafaaakeaacaaMc8UaaGPaVlaadIhacqGHRaWkcaWG5bGaeyypa0JaamyyaiaaykW7caaMc8UaaGPaVdaa@46B9@</annotation>   </semantics>  </math> </p>

And I want to have it substituted by this one:

<p>Question 06: If  <math>    <mrow>     <mtext>&#8201;</mtext><mtext>&#8201;</mtext><mi>x</mi><mo>+</mo><mi>y</mi><mo>=</mo><mi>a</mi><mtext>&#8201;</mtext><mtext>&#8201;</mtext><mtext>&#8201;</mtext>    </mrow>    <annotation encoding='MathType-MTEF'>MathType@MTEF@5@5@+=feaagCart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbwvMCKfMBHbqedmvETj2BSbqefm0B1jxALjhiov2DaerbuLwBLnhiov2DGi1BTfMBaebbnrfifHhDYfgasaacH84rpq0xbbf9q8WrFfeuY=Hhbbf9v8qqGqFr0xc9LqFj0lXxbba9Lqpepi0xhr=Fc9vqpeuj0lXdb9GqFj0dd9qqaqpi0xe9Gq=Fhrpe0dc8meaabaqaciaacaGaaeqabaWaaqaafaaakeaacaaMc8UaaGPaVlaadIhacqGHRaWkcaWG5bGaeyypa0JaamyyaiaaykW7caaMc8UaaGPaVdaa@46B9@</annotation>  </math> </p>

(Of course the bold ... is present only here, for the sake of clearness.)

Thanks,
fskilnik.
0
Comment
Question by:fskilnik
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40001640
update table
set field = replace(replace(field, '<semantics>', ''), '</semantics>', '')

to test it out and make sure this is what you want:

select replace(replace(field, '<semantics>', ''), '</semantics>', '')
from table
0
 

Author Closing Comment

by:fskilnik
ID: 40001697
Perfect, Kyle! Thanks a lot.

Regards,
fskilnik.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question