title: Issue with parameters in SQL Server stored procedures
body: <p>I remember reading a while back that randomly SQL Server can slow down and / or take a stupidly long time to execute a stored procedure when it is written like:</p>
  
  <pre><code>CREATE PROCEDURE spMyExampleProc
  (
     @myParameterINT
  )
  AS
  BEGIN
  
     SELECT something FROM myTable WHERE myColumn = @myParameter
  
  END
  </code></pre>
  
  <p>The way to fix this error is to do this:</p>
  
  <pre><code>CREATE PROCEDURE spMyExampleProc
  (
     @myParameterINT
  )
  AS
  BEGIN
     DECLARE @newParameter INT
     SET @newParameter = @myParameter
  
     SELECT something FROM myTable WHERE myColumn = @newParameter 
  END
  </code></pre>
  
  <p>Now my question is firstly is it bad practice to follow the second example for all my stored procedures? This seems like a bug that could be easily prevented with little work, but would there be any drawbacks to doing this and if so why?</p>
  
  <p>When I read about this the problem was that the same proc would take varying times to execute depending on the value in the parameter, if anyone can tell me what this problem is called / why it occurs I would be really grateful, I cant seem to find the link to the post anywhere and it seems like a problem that could occur for our company.</p>