title: parameters for view in SQL server
body: <p>In SQL Server 2005, I have a complex view that needs to specify additional conditions on certain relations.  These conditions are not known at the time of view creation.  Here's a greatly simplified version.  </p>
  
  <pre><code>SELECT fields FROM table1 
  LEFT JOIN table2 ON ((table1.pid = table2.fid) AND (table2.condition1 = @runtimecondition));
  LEFT JOIN table3 ON ....
  LEFT JOIN table4 ON .... 
  LEFT JOIN table5 ON ....
  </code></pre>
  
  <p>Dynamic SQL to directly access the tables and do the joins is not an option for me because of 3rd party constraints (this is an integration and they want to have a single point of access for me code, preferably a view -- rather than grant access to a variety of tables).  Can this be done with a view?  Do I have to use a stored procedure?  Is this a problem that could be addressed by a Table Valued Function?</p>