title: Passing parameters to a SQL view
body: <p>I have a SQL view, and I want to filter it using parameters passed to it. I was thinking about creating a stored procedure, however, after some research, I came to the conclusion that this is not possible.</p>
  
  <p>Other similar threads suggested either creating a stored function or a stored procedure with the View's code embedded into it. My question is, what is the most efficient way to perform such task. My view is made up of around 70 lines of code, just for the record. What do you think? Below are some snippets that are taken from another thread.</p>
  
  <p>The stored procedure would look like</p>
  
  <pre><code>CREATE PROCEDURE s_emp
  (
      @enoNumber INT
  ) 
  AS 
  SQL VIEW CODE + 
  WHERE 
      parameter=@stored_parameter
  </code></pre>
  
  <p>Or the user defined function would look like</p>
  
  <pre><code>CREATE FUNCTION u_emp
  (   
      @enoNumber INT
  )
  RETURNS TABLE 
  AS
  RETURN 
  (
      SQL VIEW CODE + 
      WHERE     
          parameter=@stored_parameter
  )
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/1687279/can-we-pass-parameter-to-a-view-in-sql?noredirect=1&amp;lq=1%22Source%22">Source Thread</a></p>