--函数
--返回类型:表(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