首页 > 其他 > 详细

内联表值函数FUNCTION

时间:2015-03-20 06:44:03      阅读:309      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!