title: Replace hard-coded values in stored procedure with values from table
body: <p>I have a stored procedure with hard-coded values in it (<code>CASE statement</code>). Now these hard-coded values are already stored in a different table so I would like the retrieve them from the table instead of having them hard-coded in the Stored Procedure.<br>
  In other words, I want to replace the values in the <code>CASE</code> and retrieve them from the table. I'm not sure how to go about this.<br>
  This is the table that contains the values.</p>
  
  <p>EDIT: The values in the table will often change. (Ex: Let's say I change the other_value from 25 to 35).  When executed, I want the stored procedure to dynamically retrieve the (currently hard-coded values) from the table.  (Ex: the value 25 would be replaced by 35 in the stored procedure because it will have been dynamically changed upon execution). Instead of having 10, 25, 30 as values directly hard-coded in the stored procedure, I replace them with variables(?) that will contain the current contents of the table I have for these values.  </p>
  
  <p><img src="https://i.stack.imgur.com/qnsbx.png" alt="enter image description here"></p>
  
  <pre><code>CREATE    PROCEDURE [dbo].[sp_Update_Proc]
  AS
  BEGIN
  
  Update dbo.MyTable
   set Nb1=0, Nb2=0, Nb3= b.TotalAmount, MaxValue =
     CASE   WHEN b.TotalAmount &lt; 10                               THEN 25
            WHEN b.TotalAmount &gt;= 10  and b.TotalAmount &lt; 20      THEN 50
            WHEN b.TotalAmount &gt;= 20  and b.TotalAmount &lt; 30      THEN 100
  
     END
  
  From  dbo.Client_stuff cmta
     INNER Join otherTable b
     ON b.someValue=cmta.someValue
          where yesInd=1
  
  END
  </code></pre>