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.
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 ....
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?
