title: Replace exact word in SQL Server 2016, Replace function is working as "Like" but not exact
body: <p>I have an issue related to the <code>REPLACE</code> function. I have a string which contain words like <code>SOB40</code> and <code>SOB400</code>, want to replace with the exact string match with <code>SOB40</code> not <code>SOB400</code>.</p>
  <p>I used the <code>REPLACE</code> function, but it is replacing both the words.</p>
  <p>Below is the code snippet:</p>
  <pre><code>DECLARE @x varchar(max) = '[{&quot;propertyName&quot;:&quot;Test&quot;,&quot;propertyValue&quot;:&quot;12345&quot;}]',
          @y varchar(max) =
          '{{&quot;sNumber&quot;:40,&quot;name&quot;:&quot;bush&quot;,&quot;description&quot;:&quot;bush&quot;,&quot;suggested&quot;:[&quot;nnm&quot;],&quot;Names&quot;:[&quot;676&quot;],&quot;behaviors&quot;:[&quot;uy&quot;],&quot;documents&quot;:[],&quot;propertyValues&quot;:[{ &quot;propertyName&quot;: &quot;OPs&quot;, &quot;propertyValue&quot;: &quot;08/26 13:22&quot; },SOB40]},{&quot;sNumber&quot;:400,&quot;name&quot;:&quot;as&quot;,&quot;description&quot;:&quot;u&quot;,&quot;Names&quot;:[&quot;jll&quot;],&quot;documents&quot;:&quot;5656&quot;,&quot;propertyValues&quot;:[{ &quot;propertyName&quot;: &quot;nn&quot;, &quot;propertyValue&quot;: &quot;01/05 12:59&quot; },SOB400]}}'
  
  SELECT
      @x = REPLACE(@y, ',SOB40', + SUBSTRING(@x, 2, LEN(@x) - 2))
  
  SELECT @x
  </code></pre>
  <p>Output:</p>
  <pre><code>{{&quot;sNumber&quot;:40,&quot;name&quot;:&quot;bush&quot;,&quot;description&quot;:&quot;bush&quot;,&quot;suggested&quot;:[&quot;nnm&quot;],&quot;Names&quot;:[&quot;676&quot;],&quot;behaviors&quot;:[&quot;uy&quot;],&quot;documents&quot;:[],&quot;propertyValues&quot;:[{ &quot;propertyName&quot;: &quot;OPs&quot;, &quot;propertyValue&quot;: &quot;08/26 13:22&quot; }{&quot;propertyName&quot;:&quot;Test&quot;,&quot;propertyValue&quot;:&quot;12345&quot;}]},{&quot;sNumber&quot;:400,&quot;name&quot;:&quot;as&quot;,&quot;description&quot;:&quot;u&quot;,&quot;Names&quot;:[&quot;jll&quot;],&quot;documents&quot;:&quot;5656&quot;,&quot;propertyValues&quot;:[{ &quot;propertyName&quot;: &quot;nn&quot;, &quot;propertyValue&quot;: &quot;01/05 12:59&quot; }{&quot;propertyName&quot;:&quot;Test&quot;,&quot;propertyValue&quot;:&quot;12345&quot;}0]}}
  </code></pre>
  <p>If you observe <code>propertyValue&quot;:&quot;12345&quot;}**0**]}}</code> , here we are getting zero this is happening because of replace function.</p>
  <p>Note: Tried Searching on internet, they are so many solutions, but none of them worked.</p>
  <p>Also found solutions mentioning as <code>regx</code> replace, but when I copied the function to my SSMS, it says function not found.</p>