Invalid length parameter passed to the RIGHT function in update statement
<p>does anybody know why my update is not working if I try to set two of the columns at the same time?</p>

<pre><code>  UPDATE mytable
    SET [Customer] = RIGHT([Customer], CHARINDEX('#', REVERSE([Customer])) -1) ,
        [Segment] = RIGHT([Segment], CHARINDEX('#', REVERSE([Segment])) -1)
    WHERE CHARINDEX('#', [Customer]) &gt; 0 OR
              CHARINDEX('#', [Segment]) &gt; 0
</code></pre>

<p>If I run the query with updating just one column, then it works as it is expected to work. If I run with both, I get the following err:</p>

<pre><code>Invalid length parameter passed to the RIGHT function. The statement has been terminated.
</code></pre>

<p>I know that this can happen when CHARINDEX returns 0 but I am trying to control that with the WHERE clause.</p>