sql server - Replace hard-coded values in stored procedure with values from table -


i have stored procedure hard-coded values in (case statement). these hard-coded values stored in different table retrieve them table instead of having them hard-coded in stored procedure.
in other words, want replace values in case , retrieve them table. i'm not sure how go this.
table contains values.

edit: values in table change. (ex: let's change other_value 25 35). when executed, want stored procedure dynamically retrieve (currently hard-coded values) table. (ex: value 25 replaced 35 in stored procedure because have been dynamically changed upon execution). instead of having 10, 25, 30 values directly hard-coded in stored procedure, replace them variables(?) contain current contents of table have these values.

enter image description here

create    procedure [dbo].[sp_update_proc] begin  update dbo.mytable  set nb1=0, nb2=0, nb3= b.totalamount, maxvalue =    case   when b.totalamount < 10                               25           when b.totalamount >= 10  , b.totalamount < 20      50           when b.totalamount >= 20  , b.totalamount < 30      100     end   dbo.client_stuff cmta    inner join othertable b    on b.somevalue=cmta.somevalue         yesind=1  end 

i think you're looking passing parameters stored procedure. can speculate on you've provided though. below achieves this:

create    procedure [dbo].[sp_update_proc] @int1 int , @int2 int begin  update dbo.mytable set nb1=0, nb2=0, nb3= b.totalamount, maxvalue = case   when b.totalamount < @int1                               25       when b.totalamount >= @int1  , b.totalamount < @int2      50       when b.totalamount >= @int2  , b.totalamount < 30      100  end   dbo.client_stuff cmta inner join othertable b on b.somevalue=cmta.somevalue     yesind=1  end 

Comments