ITPub博客

首页 > Linux操作系统 > Linux操作系统 > SQL Server 函數返回多個值

SQL Server 函數返回多個值

原创 Linux操作系统 作者:hky87 时间:2013-03-18 11:49:44 0 删除 编辑
内联表值型自定义函数
CREATE FUNCTION dbo.test()

RETURNs TABLE

AS

  Return
(
select 0 a,1 b
)

select * from dbotest()

多声明表值型自定义函数
CREATE FUNCTION fun_test
(
    -- Add the parameters for the function here
    @a numeric(10,2),
    @b numeric(10,2)
)
RETURNS
@tab TABLE
(
    -- Add the column definitions for the TABLE variable here
    aa int,
    bb int
)
AS
BEGIN
    -- Fill the table variable with the rows for your result set
    insert into @tab values(1,2)

    RETURN
END
GO

select aa,bb from dbo.test(1.0,2.0)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10314474/viewspace-756378/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-10-09

  • 博文量
    87
  • 访问量
    345410