title: Stored procedure get parameter list and current values
body: <p>Not sure how to implement this, but I need a way to get the current list of parameters for a stored procedure as well as their passed in values (this code will be executed in the stored procedure itself).</p>
  
  <p>I know I can use <code>sys.parameters</code> to get the parameter names, but how to get the actual values?</p>
  
  <p>What I need to do with this is to make a char string of the form </p>
  
  <pre><code>@param_name1=@value1,@param_name2=@value2,...,@param_namen=@valuen
  </code></pre>
  
  <p>I have tried to use dynamic sql, but not having much joy with that. </p>
  
  <p>Any ideas??</p>
  
  <p>Edit:</p>
  
  <p>Currently I am just going through all the parameters one-by-one to build the string. However I want a "better" way to do it, since there are quite a few parameters. And incase parameters are added later on (but the code to generate the string is not updated).</p>
  
  <p>I tried using dynamic sql but gave up, since the <code>sp_executesql</code> sp requires parameters be passed into it...</p>