Inline Table-Valued Functions
Inline TVFs are reusable table expressions that support input parameters. In all respects except for the
support for input parameters, inline TVFs are similar to views. For this reason, I like to think of inline
TVFs as parameterized views, even though they are not called this formally.
For example, the following code creates an inline TVF called GetCustOrders in the TSQL2012
database.
USE TSQL2012;
IF OBJECT_ID('dbo.GetCustOrders') IS NOT NULL
DROP FUNCTION dbo.GetCustOrders;
GO
CREATE FUNCTION dbo.GetCustOrders
(@cid AS INT) RETURNS TABLE
AS
RETURN
SELECT orderid, custid, empid, orderdate, requireddate,
shippeddate, shipperid, freight, shipname, shipaddress, shipcity,
shipregion, shippostalcode, shipcountry
FROM Sales.Orders
WHERE custid = @cid;
GO
www.it-ebooks.info
Do'stlaringiz bilan baham: |