Solved

REPLACE a certain string in a certain field

Posted on 2014-04-15
2
187 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 39

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now