您的位置:首页 > 数据库

SQL存储过程中调用返回表类型参数的函数的一种实现

2008-09-27 16:50 701 查看
--函数

--返回类型:表(table)

Create Function FunTest

(

@Para1 Type(Length),

@Para2 Type(Length),

--……

@ParaN Type(Length)

)

return @Table table

(

Col1 Type(Length),

Col2 Type(Length),

--……

ColN Type(Length)

)

as

begin

--【函数实体】

--填充表数据内容

--……Insert into @Table……

--……Update @Table set……

return

end

--存储过程

--返回数据表

Create Proc ProcTest

(

@Para1 Type(Length),

@Para2 Type(Length),

--……

@ParaN Type(Length)

)

as

--表变量定义

declare @Table table

(

Col1 Type(Length),

Col2 Type(Length),

--……

ColN Type(Length)

)

declare @P1 Type(Length)

--……

declare @PN Type(Length)

begin

【存储过程实体】

Insert into @Table select * from FunTest(参数) where (条件)<与SQL查询语句一致>

--……

--……

select * from @Table

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐