Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change a value between two characters SQL
    primarykey
    data
    text
    <p>This question is divided into two parts. I will start with the first and obvious to the title:</p> <p>On the frontend I save this value:</p> <p>Hello you are: HERE The page you can visite is www.test.se</p> <p>In the db i am trying to write a script that will change the value between ":" and "The"</p> <p>Although the value that is stored is a bit diffirent in the db...there it looks like this:</p> <pre><code>"Hello you are: &lt;br/&gt; &lt;br/&gt; &lt;br/&gt; HERE &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;The page you can visite is" www.test.se </code></pre> <p>I want to change "HERE" to "XXXX"</p> <p>My attempt so far:<br> I found these two soloutions that are simillar to my question </p> <p><a href="https://stackoverflow.com/questions/6388432/how-to-extract-strings-between-two-special-characters-in-tsql">Soloution One</a></p> <p><a href="https://stackoverflow.com/questions/16784117/using-charindex-len-and-substring-to-locate-certain-information-from-a-column">Soloution Two</a></p> <p>Sadly i could not get this to work...I attempted this:</p> <pre><code>select SUBSTRING( body, CHARINDEX(':', body) +1 , CHARINDEX('The',body)) from @temp </code></pre> <p>I read up on substring and i am aware of that the last paramater is how long from the start position it should go but i want it to stopp at "The" and dont really know how to.</p> <p>Second part of this question:</p> <p>I only want to change the value of "HERE" how can i do that and avoid deleting the br taggs? </p> <p>EDIT:</p> <p>The value that i am trying to change is not always the same so a simple update statment will not work, thats why i need to find the value that i want to change</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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