Parameterized Views
On SQL Server, an inline table-valued function is as close as you can get to a parameterized view. Like a view, an inline function doesn't have a body. It consists of a SELECT statement only. Of course, the SELECT may include unions and complex joins, but regardless it's still just a single SELECT. What an inline table gives you is a way to pass parameters into the SELECT. That is, instead of having to construct a WHERE clause every time you want to filter the view, with an inline function, you just pass in parameters. This is syntactically more concise and less error prone, and it gives you greater control over the query plan that will be produced. Oftentimes, when applying complex filter criteria in a SELECT that accesses ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access