码迷,mamicode.com
首页 > 其他好文 > 详细

内联表值函数FUNCTION

时间:2015-03-20 06:46:27      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:

创建一个内联表值函数:

 1 USE TSQLFundamentals2008;
 2 IF OBJECT_ID(dbo.fn_GetCustOrders) IS NOT NULL
 3   DROP FUNCTION dbo.fn_GetCustOrders;
 4 GO
 5 CREATE FUNCTION dbo.fn_GetCustOrders
 6   (@cid AS INT) RETURNS TABLE
 7 AS
 8 RETURN
 9   SELECT orderid, custid, empid, orderdate, requireddate,
10     shippeddate, shipperid, freight, shipname, shipaddress, shipcity,
11     shipregion, shippostalcode, shipcountry
12   FROM Sales.Orders
13   WHERE custid = @cid;
14 GO

对这个函数进行查询:

1 SELECT orderid, custid
2 FROM dbo.fn_GetCustOrders(1) AS CO;

 

内联表值函数FUNCTION

标签:

原文地址:http://www.cnblogs.com/laixiancai/p/4352559.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!