Compared with stored procedures, views have one serious limitation—they do not support parameters. Fortunately, you can use a table-valued user-defined function as a dynamic view, which does support parameters (you can also call them parameterized views):
Create Function dbo.fnlnventoryByLocationId( @LocationId int) Returns Table AS Return (SELECT * FROM dbo.vInventory WHERE LocationId = OLocationId}
They can be referenced in the From clause of a Select statement, which makes them work like a view:
select * from dbo.fnInventoryByLocationId (2)
We will discuss table-valued user-defined functions in Chapter 10.